Adobe 26001360 Scripting Guide - Page 294
DoJavaScript, ActiveDocument
UPC - 718659321840
View all Adobe 26001360 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 294 highlights
294 Visual Basic Reference WEND msgbox "Done" DoJavaScript and DoJavaScriptFile can be used to invoke script written in JavaScript for Illustrator. Please refer to the JavaScript documentation for how to write JavaScripts for Illustrator. Both methods returns the value of the last executed JavaScript statement. The following script will display an alert using the JavaScript alert method. appRef.DoJavaScript "alert( 'Number of open documents: ' + documents.length);" The string argument to DoJavaScript(), which must evaluate to a valid JavaScript expression, here returns the number of open documents to Visual Basic. Dim myNumberOfDocuments myNumberOfDocuments = appRef.DoJavaScript("documents.length;") MsgBox myNumberOfDocuments Example 1.1 In this script, we use the application property ActiveDocument to copy the current document's selection to the clipboard before pasting it into our new document. This script demonstrates how to create a new document with a specific color space and dimensions. Dim appRef As New Illustrator.Application Dim newDocument As Illustrator.Document 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 12 Aug 03