This post will attempt to introduce newcomers to Illustrator Visual Basic Scripting (well, not actually vbs, but rather tru VBA, Visual Basic for Applications). I personally prefer vba over bvs for a number of reasons. First, I always have Excel and Illustrator open, so it makes sense for me use it to drive Ai. Second, I usually need to transfer data between the two programs. Third...I love the Excel IDE...ok, let's get right into it.
- Open Excel
- hit Alt+F11, to bring up the editor
- in the Tools menu, click on References...
- add a reference to "Adobe Illustrator CS5 Type Library"
- in the Personal.xls (or in any other book) add a Module. Personal is a global workbook that is always available. If you don't see it, go back to Excel and record a macro, anything will do. That will create the Personal file.
- and type the following in that module
- we have to continue the tradition and do the "HelloWorld" script
Sub helloWorld() Dim iapp As New Illustrator.Application Dim idoc As Illustrator.Document Dim iframe As Illustrator.TextFrame Set idoc = iapp.ActiveDocument Set iframe = idoc.TextFrames.Add iframe.Contents = "Hello World from Excel VBA!!" Set iframe = Nothing Set idoc = Nothing Set iapp = Nothing End Sub
- save Personal book
- open Illustrator and create a new document first
- to run, move the cursor anywhere inside the Sub...End Sub and hit F5
that's it for now...in the following posts we'll move the text to the middle of the page, create new documents, get data from an Excel Range to Illustrator, get data from Illustrator text frame to an Excel Range...and more, hopefully.
questions? comments?