If this guide is distributed with software that includes an end user agreement, this guide, as well as the software
described in it, is furnished under license and may be used or copied only in accordance with the terms of such license.
Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written
permission of Adobe Systems Incorporated. Please note that the content in this guide is protected under copyright law
even if it is not distributed with software that includes an end user license agreement.
The content of this guide is furnished for informational use only, is subject to change without notice, and should not be
construed as a commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or
liability for any errors or inaccuracies that may appear in the informational content contained in this guide.
Please remember that existing artwork or images that you may want to include in your project may be protected under
copyright law. The unauthorized incorporation of such material into your new work could be a violation of the rights of
the copyright owner. Please be sure to obtain any permission required from the copyright owner.
Any references to company names in sample templates are for demonstration purposes only and are not intended to
refer to any actual organization.
Adobe, the Adobe logo, Acrobat, Flash, Illustrator, Macromedia, and Photoshop are either registered trademarks or
trademarks of Adobe Systems Incorporated in the United States and/or other countries.
Macintosh is a trademark of Apple Computer, Incorporated, registered in the United States and other countries. Windows
is either a registered trademark or trademark of Microsoft Corporation in the United States and other countries.
JavaScript and all Java-related marks are trademarks or registered trademarks of Sun Microsystems, Incorporated in the
United States and other countries.
All other trademarks are the property of their respective owners.
Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA. Notice to U.S. Government End Users.
The Software and Documentation are “Commercial Items,” as that term is defined at 48 C.F.R. §2.101, consisting of
“Commercial Computer Software” and “Commercial Computer Software Documentation,” as such terms are used in 48
C.F.R. §12.212 or 48 C.F.R. §227.7202, as applicable. Consistent with 48 C.F.R. §12.212 or 48 C.F.R. §§227.7202-1 through
227.7202-4, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are
being licensed to U.S. Government end users (a) only as Commercial Items and (b) with only those rights as are granted
to all other end users pursuant to the terms and conditions herein. Unpublished-rights reserved under the copyright
laws of the United States. Adobe Systems Incorporated, 345 Park Avenue, San Jose, CA 95110-2704, USA. For U.S.
Government End Users, Adobe agrees to comply with all applicable equal opportunity laws including, if appropriate, the
provisions of Executive Order 11246, as amended, Section 402 of the Vietnam Era Veterans Readjustment Assistance Act
of 1974 (38 USC 4212), and Section 503 of the Rehabilitation Act of 1973, as amended, and the regulations at 41 CFR
Parts 60-1 through 60-60, 60-250, and 60-741. The affirmative action clause and regulations contained in the preceding
sentence shall be incorporated by reference.
This reference section describes the objects and methods in the Illustrator VBScript type library. All of the
classes in the type library are presented alphabetically. The chapter concludes with an enumerations
reference which lists all of the enumerations in the Illustrator type library.
Each class listing includes the following:
Properties of the class — These include value type, read-only status, and an explanation.
Methods for the class — Value types needed by the method are shown in bold face. Enumerated
values are linked to the Chapter 2, “Enumerations Reference
All items surrounded by brackets (
Script examples — These example are intended to illustrate concepts, and do not necessarily
represent the best or most efficient way to construct a VBScript script. They contain little error
checking, and assume that the proper context exists for the scripts to execute in (for instance, that
there is a document open or items selected).
Each script contains a single subroutine that can be pasted into any event in a VBScript form if you are
using the VBScript development environment. A standard button click event is used for all examples. If
you are using a built-in VBScript editor in a VBA application, you can paste the script into a macro
routine. In either case, modify the
[ ]) are optional.
Sub statement in the example to work with your situation.
.” Required terms are shown in plain face.
For an overview of how the Illustrator object model is structured, see Adobe Illustrator CS6 Scripting Guide.
7
CHAPTER 1: VBScript Object ReferenceApplication 8
Application
The Adobe Illustrator application object, which contains all other Illustrator objects.
Application properties
PropertyValue typeWhat it is
ActionIsRunningBoolean
ActiveDocumentDocument
ApplicationApplication
BrowserAvailableBoolean
BuildNumberString
ColorSettingsListVariant
CoordinateSystem
DefaultColorSettingsString
DocumentsDocuments
FlattenerPresetsListVariant
FreeMemoryLong
LocaleString
AiCoordinateSystem
Read-only. If true, an action is still running.
The active (frontmost) document in Illustrator.
Read-only. The Illustrator Application object.
Read-only. If true, a Web browser is available.
Read-only. The application’s build number.
Read-only. The list of color-settings files
currently available for use.
The coordinate system currently in use,
document or artboard.
Read-only. The default color-settings file for the
current application locale.
Read-only. The documents in the application.
Read-only. The list of flattener style names
currently available for use.
Read-only. The amount of unused memory (in
bytes) within the Illustrator partition.
Read-only. The application’s locale.
NameString
PathString
PDFPresetsList
PPDFileList
PreferencesPreferences
PrinterListVariant
PrintPresetsListVariant
ScriptingVersionString
Variant Array of
String
Variant Array of
Strings
Read-only. The application’s name (not related to
the filename of the application file).
Read-only. The file path to the application.
Read-only. The list of preset PDF-options names
available for use.
Read-only. The list of PPD files currently available
for use.
Read-only. The application preferences.
Read-only. A list of available printers.
Read-only. The list of preset printing-options
names currently available for use.
Read-only. The version of the Scripting plug-in.
CHAPTER 1: VBScript Object ReferenceApplication 9
PropertyValue typeWhat it is
Selection
StartupPresetsListVariant
TextFontsTextFonts
TracingPresetList
UserInteractionLevelAiUserInteractionL
VersionString
VisibleBoolean
Application methods
MethodReturnsWhat it does
ConcatenateMatrix
(matrix as Matrix,
secondMatrix as Matrix)
Variant
objects
Variant
String
evel
Array of
Array of
All currently selected objects in the active
(frontmost) document.
Read-only. The list of presets available for
creating a new document.
Read-only. The installed fonts.
Read-only. The list of preset tracing-options
names available for use.
The allowed level of interaction with users in the
form of dialogs and message boxes.
Read-only. The version of the Illustrator
application.
Read-only. If true, the application is visible.
Matrix
Concatenates two
matrices.
ConcatenateRotationMatrix
(matrix as Matrix,
angle as Double)
ConcatenateScaleMatrix
(matrix as Matrix,
[, scaleX as Double]
[, scaleY as Double])
ConcatenateTranslationMatrix
(matrix as Matrix,
[, deltaX as Double]
[, deltaY as Double])
ConvertSampleColor
(SourceColorSpace as AiImageColorSpace
SourceColor as ColorComponents,
DestColorSpace as AiImageColorSpace
ColorConvertPurpose as AiColorConvertPurpose
[,SourceHasAlpha as Boolean]
[,DestHasAlpha as Boolean])
Copy
()
Cut
()
,
Matrix
Concatenates a rotation to
a transformation matrix.
Matrix
Concatenates a scale to a
transformation matrix.
Matrix
Concatenates a translation
to a transformation matrix.
,
array of
ColorCom
ponents
Converts a
sample-component color
from one color space to
another.
' Open a document and get the reference to it
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Open("C:\temp\aFile.ai")
Accessing the selection
In Illustrator, the application’s Selection can be accessed as well as modified. The selection will contain
Empty when there are no selected objects. To deselect all objects in the current document, set the
selection to
Set appRef = CreateObject("Illustrator.Application")
appRef.activeDocument.Selection = Empty
Empty, as the following example shows.
A reference to a text range is returned when there is an active insertion point in the contents of a
TextFrame. Similarly, a reference to a range of text is returned when characters are selected in the
contents of a
TextFrame.
Executing an action
You can run an action from the Action Palette from a script by using the DoScript method. When you do
this, the control returns to your script before the action has completed. Use the
ActionIsRunning
property to test for when the action has completed before executing any other VBScript methods (see the
Windows.DoAction example). You can also use the Sleep method defined on the WScript object to insert
a pause to test this property, as in the following example:
This script uses the application property ActiveDocument to copy the current document’s selection to the
clipboard before pasting it into our new document. This script also demonstrates how to create a new
document with a specific color space and dimensions.
'Duplicates the selected item in the current document to a new document
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
If Not IsEmpty(appRef.ActiveDocument.selection) Then
appRef.ActiveDocument.Copy
Set newDocument = appRef.Documents.Add(aiDocumentCMYKColor,250, 400)
newDocument.Paste
End If
End If
CHAPTER 1: VBScript Object ReferenceArtboard 15
Artboard
An Artboard object represents a single artboard in a document. There can be between 1 to 100 artboards
in one document.
Artboard properties
PropertyValue typeWhat it is
ApplicationApplication
ArtboardRectRect
NameString
ParentDocument
RulerOriginPoint
RulerPARDouble
ShowCenterBoolean
ShowCrossHairsBoolean
ShowSafeAreasBoolean
Artboard methods
MethodReturnsWhat it does
Read-only. The Illustrator Application object.
Size and position of the artboard.
The unique identifying name of the artboard.
Read-only. The name of the object that is this Artboard object’s
parent.
Ruler origin of the artboard, relative to the left top corner of the
artboard.
Pixel aspect ratio, used in ruler visualization if the units are pixels.
Range: 0.1 to 10.0
Show center mark.
Show cross hairs.
Show title and action safe areas (for video).
Delete
()
NothingDeletes this artboard object. You cannot remove the last
artboard in a document.
CHAPTER 1: VBScript Object ReferenceArtboards 16
Artboards
A collection of artboards.
Artboards properties
PropertyValue typeWhat it is
ApplicationApplication
CountLong
ParentDocument
Artboards methods
MethodReturnsWhat it does
Add
(rect as ArtboardRect)
GetActiveArtboardIndex
()
GetByName
(artboardName as String)
Index
(item as DataSets)
Insert
(rect as ArtboardRect,
index as Long)
Read-only. The Illustrator Application object.
Read-only. The number of objects in the collection.
Read-only. The document that contains this object.
Artboard
Long
Creates a new Artboard object.
Retrieves the index position of the active artboard in the
document's list. Returns the 0-based index.
Artboard
Retrieves an artboard object from the list by its unique
identifying name.
Long
Returns the index position of the object within the
collection.
NothingCreates a new artboard object and inserts it at the given
index in the list.
Item
(itemKey)
Remove
(index as Long)
SetActiveArtboardIndex
(index as Long)
Artboard
Returns an object reference to the object identified by
itemKey (name or index).
NothingDeletes an artboard object. You cannot remove the last
artboard in a document.
NothingMakes a specific artboard active and makes it current in
'Opens a document and adds a simple text frame, then
'uses the CharacterAttributes object to increment
'the horizontal and vertical scale of each character.
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Documents.Add()
Set textRef = docRef.TextFrames.Add()
textRef.Contents = "I'd rather be scripting!"
textRef.Top = 500
textRef.Left = 40
dSize = 100
iCount = textRef.Characters.Count
i = 1
Dim charRef
Do While (i < (iCount + 1))
A collection of TextRange objects in which each represents a single character.
Characters properties
PropertyValue typeWhat it is
ApplicationApplication
CountLong
Parent
ObjectRead-only. The object’s container.
Characters methods
MethodReturnsWhat it does
Add
(contents as String
[, relativeObject as TextFrame]
[, insertionLocation as AiElementPlacement
AddBefore
(contents as String)
Read-only. Application that the collection belongs to.
Read-only. Number of elements in the collection.
TextRange
Adds a new character with
specified text contents at
])
the specified location in the
current document. If
location is not specified,
adds the new character to
the containing text frame
after the current text
selection or insertion point.
TextRange
Adds a character before the
current text selection or
insertion point.
Index
(itemPtr as TextRange)
RemoveAll
()
Long
Returns the index position
of the object within the
collection.
NothingDeletes every element in
the collection.
CHAPTER 1: VBScript Object ReferenceCharacters 25
Counting characters
'Counts the number of characters in the current document
'and stores the result in numChars
Set appRef = CreateObject("Illustrator.Application")
If appRef.Documents.Count > 0 Then
numChars = 0
For Each textArt In appRef.ActiveDocument.TextFrames
Set textArtRange = textArt.TextRange
numChars = numChars + textArtRange.length
'Opens a document, adds 3 text frames,
'creates a new character style and applies it to
'each of the text frames
Set appRef = CreateObject("Illustrator.Application")
'Create a new document add a 3 simple text items
Set docRef = appRef.Documents.Add()
Set textRef1 = docRef.TextFrames.Add()
textRef1.Contents = "Scripting is fun!"
textRef1.Top = 700
textRef1.Left = 50
Set textRef2 = docRef.TextFrames.Add()
textRef2.Contents = "Scripting is easy!"
textRef2.Top = 625
textRef2.Left = 100
Set textRef3 = docRef.TextFrames.Add()
textRef3.Contents = "Everyone should script!"
textRef3.Top = 550
textRef3.Left = 150
appRef.Redraw
'Create a new character style
Set charStyle = docRef.CharacterStyles.Add("BigRed")
'Create a red color
Set colorRed = CreateObject("Illustrator.RGBColor")
colorRed.Red = 255
'Set character attributes of the new style
With charStyle.CharacterAttributes
.Size = 40
.Tracking = -50
.Capitalization = 0 'aiNormalCaps
.FillColor = colorRed
End With
'Apply style to each textFrame in the document
charStyle.ApplyTo textRef1.TextRange
charStyle.ApplyTo textRef2.TextRange
charStyle.ApplyTo textRef3.TextRange
CHAPTER 1: VBScript Object ReferenceCMYKColor 29
CMYKColor
A CMYK color specification, used to apply a CMYK color to a layer or art item.
If the color space of a document is RGB and you specify the color value for a page item in that document
using CMYK, Illustrator translates the CMYK color specification into an RGB color specification. The same
thing happens if the document’s color space is CMYK and you specify colors using RGB. Since this
translation can lose information, you should specify colors using the class that matches the document’s
actual color space.
CMYKColor properties
PropertyValue typeWhat it is
ApplicationApplication
BlackDouble
CyanDouble
MagentaDouble
YellowDouble
Read-only. The Illustrator Application object.
The black color value. Range: 0.0 to 100.0
The cyan color value. Range: 0.0 to 100.0
The magenta color value. Range: 0.0 to 100.0
The yellow color value. Range: 0.0 to 100.0
Setting CMYK colors
'Creates a new CMYK color and applies it to the first path item
Set appRef = CreateObject("Illustrator.Application")
Set newCMYKColor = CreateObject("Illustrator.CMYKColor")
'Get a reference to the frontmost path in the document
Set frontPath = appRef.ActiveDocument.PathItems(1)