Adobe 27510753 Scripting Guide - Page 152
Creating a new document, Opening a document, Document.Add, ShowingWindow
UPC - 718659445294
View all Adobe 27510753 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 152 highlights
144 Working with Documents in VBScript Adobe InDesign CS2 Scripting Guide Basic document management In almost all situations, your script needs to either open or create a document, save it, and then close it. Creating a new document If a document does not already exist, you must create one. To create a document: Rem MakeDocument.vbs Rem An InDesign CS2 VBScript Rem Creates a new document. Set myInDesign = CreateObject("InDesign.Application.CS2") Set myDocument = myInDesign.Documents.Add The Document.Add method can take two optional parameters, as shown in the following script: Rem MakeDocumentWithParameters.vbs Rem An InDesign CS2 VBScript Rem Creates a new document. Rem The first parameter (ShowingWindow) controls the visibility of the document. Rem Hidden documents are not minimized, and will not appear until you Rem create a new window. Rem The second parameter (DocumentPreset) specifies the document preset to use. Rem The following line assumes that you have defined a document Rem preset named "Flyer". Set myInDesign = CreateObject("InDesign.Application.CS2") Set myDocument = myInDesign.Documents.Add(True, myInDesign.DocumentPresets.Item("Flyer")) Rem If you set the ShowingWindow parameter to False, you can Rem show the document by creating a new window. Rem Set myLayoutWindow = myDocument.Windows.Add Opening a document The following example script shows how to open an existing document: Rem OpenDocument.vbs Rem An InDesign CS2 VBScript Rem Opens an existing document. You'll have to fill in your own file path. Set myInDesign = CreateObject("InDesign.Application.CS2") Set myDocument = myInDesign.Open("c:\myTestDocument.indd") You can choose to prevent the document from displaying (hide it) by setting the ShowingWindow parameter of the Open method to false (the default is true). You might want to do this to improve performance of a script. To show a hidden document, create a new window, as shown in the following script: Rem OpenDocumentInBackground.vbs Rem An InDesign CS2 VBScript Rem Opens an existing document in the background, then shows the document. Rem Youíll have to fill in your own file path. Set myInDesign = CreateObject("InDesign.Application.CS2") Set myDocument = myInDesign.Open("c:\myTestDocument.indd", False) Rem At this point, you can do things with the document without showing the Rem document window. In some cases, scripts will run faster when the document Rem window is not visible. Rem When you want to show the hidden document, create a new window. Set myLayoutWindow = myDocument.Windows.Add