Search code examples
javascriptadobeadobe-indesignextendscript

How to change textframe creation order in Indesign


I am writing a script for Indesign. In that script I am taking the contents of the textframes and save them to a database. Till here my script works. However when looping between textframes script uses creation order. I want to save to database in question order.

Here is my script:

var myDocument = app.activeDocument;var frameList = myDocument.textFrames;
for (var i = 0; i < frameList.length; i++){ 
    var txt=frameList[i].contents;
    SaveToDB(txt);
}

So is there a way to change creation order of textframes

Indesign I'm working with


Solution

  • Yes, there is a way to change the "creation order", you simply need to rearrange the text frames in the Layers panel. The text frame at the lowest position in the stack will be treated as if it were created first, and the one at the highest position as if it were created last.

    However, I know of no way to change this stack order via script (if somebody knows one, I would be curious to hear it).

    So your choices are to either manually rearranging this stack order in the Layers panel and then run your script or to sort it by the question numbers (as Jongware suggested over at StackExchange GraphicDesign).