• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Release anchored objects on first page of doc

Engaged ,
Jan 10, 2017 Jan 10, 2017

Copy link to clipboard

Copied

How do you release an anchored text frame from the first page of a doc?

var textFrames =   app.activeDocument.textFrames.everyItem().getElements();

                        

                         for ( i; i<textFrames.length; i++ ) {

                            

                             if ( textFrames.parentPage===app.activeDocument.pages[0] && textFrames.anchoredObjectSettings.isValid) {

                            

                             textFrames.anchoredObjectSettings.releaseAnchoredObject();

                             }

                         };

This returns that resleaseAchoredObject is undefined..

TOPICS
Scripting

Views

394

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 10, 2017 Jan 10, 2017

You're after anchored frames, but you inspect app.activeDocument.textFrames.everyItem().getElements();, which does not return anchored frames. Instead you should e.g. get a handle of all page items. You can get them on page[0], no need to get them in the whole document (and you should probably go backwards too). A frame is anchored if its parent is a character.

pItems = app.activeDocument.pages[0].allPageItems;

for (i = pItems.length-1; i >= 0; i--) {

  if (pItems.parent instanceof Character && pI

...

Votes

Translate

Translate
Community Expert ,
Jan 10, 2017 Jan 10, 2017

Copy link to clipboard

Copied

LATEST

You're after anchored frames, but you inspect app.activeDocument.textFrames.everyItem().getElements();, which does not return anchored frames. Instead you should e.g. get a handle of all page items. You can get them on page[0], no need to get them in the whole document (and you should probably go backwards too). A frame is anchored if its parent is a character.

pItems = app.activeDocument.pages[0].allPageItems;

for (i = pItems.length-1; i >= 0; i--) {

  if (pItems.parent instanceof Character && pItems.anchoredObjectSettings.anchoredPosition === AnchorPosition.ANCHORED) {

    pItems.anchoredObjectSettings.releaseAnchoredObject();

  }

}

textFrames.anchoredObjectSettings.isValid is not a useful test because every text frame has the property anchoredObjectSettings.

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines