Skip to main content
Participating Frequently
Apr 3, 2025 9:04 AM UTC
Question

Can't find textframe using doc.textFrames.itemByName("myTextFrame");

In a document i have inserted a textframe and added myTextFrame into its Script Label.

When trying to get it by js using doc.textFrames.itemByName("myTextFrame"); is says the object is invalid.

When trying doc.textFrames[0] i get a textframe with label myTextFrame.

Having same issues with rectangels -> var rect = doc.rectangles.itemByName(rectName);

 

17 replies

TᴀW
Legend
Apr 3, 2025 9:11 AM UTC

If I'm not mistaken, itemByName will get a frame according to its name in the Layers panel, not its script label.

Translate
id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
Participating Frequently
Apr 3, 2025 9:31 AM UTC

Thx. ChatGPT isn't always right

Translate
Robert at ID-Tasker
Legend
Apr 3, 2025 9:58 AM UTC

@Keld294028034yyk

 

You need to iterate either pageItems or allPageItems collections - for any item - or just textFrames collection of the document and check label property. 

 

Translate