The case was opened on Wednesday following a request from public prosecutors who argued Volkswagen may have committed fraud, violated consumer protection laws and committed crimes against the environment due to pollution from its cars.
The court ordered the company to present a judge with “all official statements over this affair”, as well as a list of all the cars that are affected by the scandal and all information regarding the installation of the software to rig diesel emissions tests in Spain.
Volkswagen sparked global outrage last month when it admitted that 11 million of its diesel cars worldwide were equipped with so-called defeat devices that activate pollution controls during emission tests but turn them off when the car is on the road.
The company earlier on Wednesday posted its first quarterly net loss in 15 years in the third quarter because of the scandal and warned it would hurt earnings for the whole of 2015.
Volkswagen is already facing criminal investigations and regulatory probes over the affair in several other nations, including France, Germany, Italy and the United States.
The company has already said it will set aside €6.5 billion in provisions in the third quarter but the company's new chief executive Matthias Mueller has acknowledged this was just the start as it only covers the estimated cost of fixing the vehicles.
Nearly 684,000 diesel cars of the Volkswagen brands – VW, Audi, Skoda and Seat – have been sold in Spain in recent years fitted with the pollution-cheating software, according to VW's Spanish unit.