Search code examples
javascriptscriptingframesadobe-indesign

How to find ALL text frames in InDesign by JavaScript


I need to find all text frames on the active page in an InDesign document and to put them into an array - in order to grab out one or many text frame(s) carrying a specific script label. I tried

myPage = app.properties.activeWindow && app.activeWindow.activePage,
myTextFrames = myPage.textFrames.everyItem().getElements();

but this doesn't bring those text frames that are -anchored; -in a table cell; -within a group. How can I get really all text frames?


Solution

  • Not in one line.

    You may need to start from myPage.allPageItems --> which returns an array AND filter it by

    1. arrayElement.constructor.name == "TextFrame"

    or

    1. arrayElement.label == "yourTargetLabel"