Skip to main content
Participating Frequently
April 3, 2025
Question

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

  • April 3, 2025
  • 1 reply
  • 1180 views

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);

 

1 reply

TᴀW
Legend
April 3, 2025

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

Participating Frequently
April 3, 2025

Thx. ChatGPT isn't always right

Robert at ID-Tasker
Legend
April 3, 2025

@Keld294028034yyk

 

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