0 Replies Latest reply on Mar 3, 2009 12:05 PM by (mps)

    Loop actions through several open documents

      I am on a mac using InDesign CS3. Code is all in Javascript.

      Trying to get a loop to work for a series of actions, the purpose is to loop through all the actions for the top document then close that document and proceed to loop through the next, and so on until all are closed.

      The problem is that since I am using Data Merge (part of the loop) a new document is created so when the loop is finished the copy is closed but the loop starts on the original document, creating an endless loop.

      In other words I have documents "A", "B", and "C" open. Loop performs on A, makes a copy at the Data merge point (call it "A.1") then closes "A.1". At this point I want it to go to "B" but instead we start again with "A" and so on endlessly.

      I wrote the following to try to skip the document on top for each cycle through but it doesn't work and I think the logic is flawed.

      for(myDocumentCounter = app.documents.length; i=0; myDocumentCounter > 0; myDocumentCounter--; i=i++){

      Is there another to accomplish this? Maybe, is there a way to have the loop perform on all open documents "at once"?