Adobe 26001360 Scripting Guide - Page 288
Referencing and creating objects in Visual Basic, myPath, Application, GetObject
UPC - 718659321840
View all Adobe 26001360 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 288 highlights
288 Visual Basic Reference paste the script into a macro routine. In either case, modify the Sub statement in the example to work with your situation. Referencing and creating objects in Visual Basic As the object model diagram shows, all objects are arranged in a hierarchy. To obtain a reference to a specific object you need to navigate the hierarchy. For example, to store a reference to the first PathItem in the second layer of the active document in the variable myPath you would write: Set myPath = appRef.ActiveDocument.layers(2).PathItems(1) Since all objects in the hierarchy are referenced through the Application object, you must have a reference to the Illustrator application before you can start modifying any other objects. There are several ways to obtain a reference to an Illustrator application object. For example, the following line will create a new reference to the Application if you have added a reference to the Illustrator type library to the project. Dim appRef As New Illustrator.Application As with New, GetObject will create a reference to a running instance of Illustrator. If Illustrator is not running an error is returned. Dim appRef As Illustrator.Application Set appRef = GetObject(, "Illustrator.Application") CreateObject will launch Illustrator as an invisible application if it is not already running. Note that if Illustrator was launched as an invisible application you have to manually activate the application to make it visible. Dim appRef As Illustrator.Application Set appRef = CreateObject("Illustrator.Application") Note: If you have both Illustrator 10 and Illustrator CS installed on the same machine and wish to use the CreateObject() or GetObject() method for obtaining an application reference, you have to be sure to use the correct PROGID string. "Illustrator.Application" always refers to the latest installed Illustrator version; in this case, Illustrator CS. To specifically target Illustrator 10, use "Illustrator.Application.1"; Illustrator CS, "Illustrator.Application.2". 12 Aug 03