I want to have a blank slate at the start of my script. My two current approaches both have downsides.

First, I create a new document at the start of the script. However, during development, I test run my script multiple times. Thus, I then have many open documents in Illustrator that I have to close by hand.

Second, if I choose the active document at the start of the script instead, it does not open new documents but it will write on top of whatever is already there.

Is there a way to select the active document but wipe it clean in the beginning of the script?

  • Be careful wiping everything in your active document.. You don't want to accidentally wipe, save and close an important doc :)
    – Cai
    May 11, 2016 at 8:47
  • 1
    Go with a new document, rather than wiping. If you have a document open, then it could be game over for that document! I'm doing the same, and find when the amount of open docs gets too much, by closing the application with ALT+F4 will ask you if you want to save them, just press ALT+n and you'll quickly close the application and all open docs. May 11, 2016 at 9:53

1 Answer 1


For every pageItem do:


This does not include swatches, symbols and other such persistent thing. As a alternative make a new document and close the old one.

  • Alternatively you can make a new document and close the old one.
    – joojaa
    May 11, 2016 at 15:14
  • How do I make a new document and close the old one in the script, esp. bypassing the "Are you sure" prompt?
    – Heisenberg
    May 11, 2016 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.