Skip to main content
Participant
April 16, 2011
Question

how to change "activeDocument"?

  • April 16, 2011
  • 1 reply
  • 578 views

Hi Guys, I am new to Illustrator scripting - actually just started today. I don't know how to change the activeDocument to recursively process all the open .ai files and generate corresponding PNG files. "documents" is an array of all open .ai files. My problem is that all the generated PNG files are the same. The alert message confirms that activeDocumen.name doesn't change, whereas the sourceDoc name recurrsively changes based on the open files.

Here is a code snipit:

            for ( i = 0; i < app.documents.length; i++ ) {
                sourceDoc = app.documents; // returns the document object
                                       
                // Get the file to save the document as pdf into
                targetFile = this.getTargetFile(sourceDoc.name, '.png', destFolder);
               
                // Export as png
                 sourceDoc.exportFile(targetFile, ExportType.PNG24, options);
                
                  alert (activeDocument.name);
                  alert (sourceDoc.name);
            }

Any help is appreciated!

Alex

This topic has been closed for replies.

1 reply

Participant
April 17, 2011

I was missing:

sourceDoc.close(SaveOptions.DONOTSAVECHANGES);

It fixed the problem. Also a more elegant solution is located at:

http://forums.adobe.com/message/3205868