Option Explicit ' This sample shows how to run Actions in Illustrator. ' An action is asynchronous so it is not guaranteed to have completed when the ' DoScript command returns. ' After issuing a DoScript command you therefore should test the property "ActionIsRunning" ' and wait for it to be false before continuing the script. ' ' The sample code has a sub-routine that does that for you: "Run_Action" ' Note the sample also uses functionality in the module "TimerModule". The code in that ' module is based on: http://support.microsoft.com/support/kb/articles/Q231/2/98.ASP ' Sleep API is declared in the form to keep the ' SetWaitableTimer code in its own re-usable module. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Command1_Click() Dim objApp As Illustrator.Application Dim objRectangle As Illustrator.PathItem Set objApp = CreateObject("Illustrator.Application") ' Create a test document objApp.Documents.Add Set objRectangle = objApp.Documents(1).PathItems.Rectangle(200, 50, 175, 220) objRectangle.Selected = True ' Now perform a standard action Run_Action objApp, "Opacity 60 (selection)", "Default Actions" End Sub ' Run_Action executes an action inside Illustrator. ' The method then waits for the action to complete before returning ' ' objApp : a reference to the Illustrator application ' ActionName: Name of the action to run ' Action Set: Name of the action set that contains the action Private Sub Run_Action(objApp As Object, ActionName As String, ActionSet As String) objApp.DoScript ActionName, ActionSet ' We now have to wait for the action to complete. ' The property ActionIsRunning can be used to test for this. ' ' If you are using Windows Scrpting Host you can use the "sleep" method ' A value of 1000 means a second ' ' If you are using VisualBasic you can use the following method ' (from: http://support.microsoft.com/support/kb/articles/Q231/2/98.ASP ) ' Note wait takes seconds as the argument While (objApp.ActionIsRunning) Wait 1 Wend ' The action has completed and we can return End Sub