Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create rectangles from info in excel file . . . Help!

Explorer ,
Jun 26, 2013 Jun 26, 2013

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?

TOPICS
Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 27, 2013 Jun 27, 2013

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

...
Translate
Adobe
Community Expert ,
Jun 26, 2013 Jun 26, 2013

are you a programmer? just not familiar with illustrator, or not a programmer at all?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 26, 2013 Jun 26, 2013

Not a programmer at all, sorry.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 26, 2013 Jun 26, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 26, 2013 Jun 26, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 26, 2013 Jun 26, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2013 Jun 27, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 27, 2013 Jun 27, 2013

Worked PERFECTLY!!! Thank you so much!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2024 Nov 22, 2024
LATEST

Hi, I need something like this, but it didnt see working in newest exel + illustrator:( 

Do you know the way to make it work? 😄 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines