Copy link to clipboard
Copied
I'm in need of help and have NO idea what I'm doing. I have an excel file with thousands of rows, each with a column for the x-coordinate, the y-coordiante, the height, and width of a rectangle. I need a script that will ask me to select the excel file, read the excel file, and create rectangles from each of the thousands of rows. I imagine this would be pretty simple for somebody who knows what they're doing, but I have no idea where to start. I'm working in a windows environment and have Illustrator CS4. Any suggestions? Any scripts out there that might give me a start?
here you go, this is VBA code, I prefer to use it when I need to have Excel talk to Illustrator directly without exporting the Excel data.
to set up...
- 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" (or CS4 or your version)
- 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, any
...Copy link to clipboard
Copied
are you a programmer? just not familiar with illustrator, or not a programmer at all?
Copy link to clipboard
Copied
Not a programmer at all, sorry.
Copy link to clipboard
Copied
can you post a screen shot, showing how your data is laid out in excel?
mac or win?
edit:
I see you're on windows
Message was edited by: CarlosCanto
Copy link to clipboard
Copied
I have the data organized a bunch of different ways and can easily adjust the excel file. As of now, there are four columns, from left to right, with values for the x-location (column A), the y-location (column B), the width (column C), and the height (column D) of each desired rectangle. All values are in points. There are no headers or labels in the excel file, but adding them would be easy enough.
If I were to do what I want manually in illustrator (like I did for hours today, getting practically nowhere), I would create a rectangle, make sure the reference point was set to the left side, and type in the x, y, width, and height numbers into the transform panel on the toolbar. There has to be a better way than doing this more than 1000 times.
Copy link to clipboard
Copied
FYI, I'm on the east coast and have to get up early tomorrow (today), so please forgive me if I don't respond again until the morning. I really appreciate any suggestions you may have for me.
Copy link to clipboard
Copied
here you go, this is VBA code, I prefer to use it when I need to have Excel talk to Illustrator directly without exporting the Excel data.
to set up...
- 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" (or CS4 or your version)
- 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
Sub makeSquares()
'carlos canto // 6/26/13
'reads the active Excel workbook data to create squares in Illustrator
'data is organized in rows as follows x, y, width, height
'data has no headers, first row in cell "A1"
Dim iapp As New Illustrator.Application
Dim idoc As Illustrator.Document
Dim isquare As Illustrator.PathItem
Dim rowcount As Integer
Dim x As Double
Dim y As Double
Dim w As Double
Dim h As Double
rowcount = Cells(1, 1).CurrentRegion.Rows.Count
Set idoc = iapp.Documents.Add
For i = 1 To rowcount
x = Cells(i, 1)
y = Cells(i, 2)
w = Cells(i, 3)
h = Cells(i, 4)
Set isquare = idoc.PathItems.Rectangle(y, x, w, h)
Next
Set isquare = Nothing
Set idoc = Nothing
Set iapp = Nothing
End Sub
- save Personal book
- to run, move the cursor anywhere inside the Sub...End Sub and hit F5
for simplicity, start illustrator before running the script
Copy link to clipboard
Copied
Worked PERFECTLY!!! Thank you so much!
Copy link to clipboard
Copied
Hi, I need something like this, but it didnt see working in newest exel + illustrator:(
Do you know the way to make it work? 😄
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more