Adobe 65010248 Scripting Guide - Page 48
Scripting with VBScript, For more information, Your first Illustrator script
UPC - 883919156484
View all Adobe 65010248 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 48 highlights
6 Scripting with VBScript This chapter uses script examples and explanations to help you to become familiar with Illustrator scripting using VBScript. For more information Several extended sample scripts are in the /Scripting/Sample Scripts folder in your Illustrator CS4 installation directory. For information about individual classes, objects, properties, methods, and parameters, as well as script samples that demonstrate how to use many of these items, see Adobe Illustrator CS Scripting Reference: VBScript, in the /Scripting/Documentation folder in your Illustrator CS4 installation directory. You also can view the Illustrator CS4 type library from most VBScript editors or any Microsoft Office application; see "Viewing the VBScript object model" on page 9. If you do not understand the concepts and terms used in this chapter, read Adobe Introduction to Scripting. Your first Illustrator script The traditional first project in any programming language is displaying the message "Hello World!" Follow these steps: 1. Start any text editor (for example, Notepad). 2. Type the following code: Rem Hello World Set appRef = CreateObject("Illustrator.Application") Rem Create a new document and assign it to a variable Set documentRef = appRef.Documents.Add Rem Create a new text frame item and assign it to a variable Set sampleText = documentRef.TextFrames.Add Rem Set the contents and position of the TextFrame sampleText.Position = Array(200, 200) sampleText.Contents = "Hello World!" 3. Save the file as text-only in a folder of your choice, using the file extension .vbs. 4. To test the script, do one of the following: ➣ Double-click the file. ➣ Start Illustrator, choose File > Scripts > Other Scripts, and navigate to and run your script file. TIP: To add the script to the Illustrator Scripts menu (File > Scripts), save the script in the Scripts folder. The script will appear on the menu the next time you start Illustrator. For details, see "Installing scripts in the Scripts menu" on page 10. In general, when you launch a VBScript script from the Scripts menu, any msgBox dialogs will not display correctly. 48