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..
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
Copy link to clipboard
Copied
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