Adobe 27510753 Scripting Guide - Page 31
VBScript, Visual Basic
UPC - 718659445294
View all Adobe 27510753 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 31 highlights
Adobe InDesign CS2 Scripting Guide Getting Started with InDesign Scripting 23 --Hello World tell application "Adobe InDesign CS2" --Create a new document and assign its --identity to the variable "myDocument" set myDocument to make document tell myDocument --Create a new text frame on the first page. tell page 1 set myTextFrame to make text frame --Change the size of the text frame. set geometric bounds of myTextFrame to {"0p0", "0p0", "18p0", "18p0"} --Enter text in the text frame. set contents of myTextFrame to "Hello World!" end tell end tell end tell 3. Save the script. 4. Run the script (click Run in the Script Editor). InDesign creates a new publication, adds a text frame, and enters text. During this process, the Script Editor might ask where your copy of InDesign is located. In this case, select the application from the list of displayed applications, and the Script Editor will remember where it is the next time you run the script. VBScript To create a VBasic script: 1. Start any text editor (Notepad, for example). 2. Enter the following code. The lines preceded by Rem are comments and are ignored by the scripting system. They're included to describe the operation of the program. As you look through the script, you'll see how we create, then address, each object in turn. You do not need to enter the comments. Rem Hello World Set myInDesign = CreateObject("InDesign.Application.CS2") Rem Create a new document. Set myDocument = myInDesign.Documents.Add Rem Get a reference to the first page. Set myPage = myDocument.Pages.Item(1) Rem Create a text frame. Set myTextFrame = myDocument.TextFrames.Add Rem Specify the size and shape of the text frame. myTextFrame.GeometricBounds = Array("0p0", "0p0", "18p0", "18p0") Rem Enter text in the text frame. myTextFrame.Contents = "Hello World!" 3. Save the file as text only to the Scripts folder in the Presets folder inside your InDesign application folder. Give the file the file extension .vbs. 4. Display the Scripts palette, if it's not already visible. Double-click the script name in the palette to run the script. Visual Basic To create a Visual Basic script (the steps shown are for Visual Basic 6; Visual Basic 5 CCE and Visual Basic.NET users will see slightly different dialog boxes): 1. Start Visual Basic and create a new project. Add the InDesign CS Type Library reference to the project, as shown earlier.