Altova XMLSpy 2024 Enterprise Edition

After you have started the application as shown in Start Application, you will most likely want to programmatically open a document in order to work with it. The JScript code listing below illustrates how to open two documents from the XMLSpy Examples folder and set one of them as the active document.

 

 

// Locate examples via USERPROFILE shell variable. The path needs to be adapted to major release versions.
objWshShell = WScript.CreateObject("WScript.Shell");
majorVersionYear = objSpy.MajorVersion + 1998
strExampleFolder = objWshShell.ExpandEnvironmentStrings("%USERPROFILE%") + "\\My Documents\\Altova\\XMLSpy" + majorVersionYear + "\\Examples\\";
 
// Tell XMLSpy to open two documents. No dialogs
objDoc1 = objSpy.Documents.OpenFile(strExampleFolder + "OrgChart.pxf", false);
objSpy.Documents.OpenFile(strExampleFolder + "ExpReport.xml", false);
 
// The document currently active can be easily located.
objDoc2 = objSpy.ActiveDocument;
 
// Let us make sure that the document is shown in grid view.
objDoc2.SwitchViewMode(0);   // SPYViewModes.spyViewGrid = 0
 
// Now switch back to the document opened first
objDoc1.SetActiveDocument();

 

 

The JScript code listed above is available in the sample file DocumentAccess.js (see Example Files).

© 2018-2024 Altova GmbH