Skip to main content
Participating Frequently
January 29, 2013
Answered

released anchored text frame and copy its content

  • January 29, 2013
  • 1 reply
  • 2352 views

Hi All,

I've got a script that will able to anchor text frame to InDesign and it is working well. Now my problem is I have to released that anchored text frames and then copy its content the same position where the text frame was anchored.

Here is what I need to do:

1. Find and achored text frame from a document (using find anchored object by its object style applied).

2. Release the found anchored object.

3. Copy its content the same position where it was been anchored.

For item 1 and 2, I may able to do it but item 3 I don't have any idea.

Hope anyone can lend me time to solve this problem.

Thanks you in advance for any help.

--elmer

This topic has been closed for replies.
Correct answer Vamitul

then, instead of myFrame.releaseAnchoredObject(); use myFrame.remove();

1 reply

Vamitul
Legend
January 29, 2013

assuming myFrames ist the array of anchores.

var l=myFrames.length;

while (l--){

myFrames.texts[0].move(LocationOptions.AFTER,myFrames.parent);

//remove anchor etc.

}

adapt snippet as needed, proof it etc (for example if the anchored frame does not contain any text it will crash and burn, so maby use a try..catch).

Participating Frequently
January 31, 2013

below is my sample script, though it is now working but what if I want to delete the anchored frame instead of releasing the object...

n = app.selection[0].textFrames.length;

while (n >= 0)

{

          try {

                    var myFrame = app.selection[0].textFrames;

                    myFrame.anchoredObjectSettings.anchoredPosition = AnchorPosition.anchored;

                    myFrame.texts[0].move(LocationOptions.AFTER,myFrame.parent);

                    myFrame.releaseAnchoredObject();

          } catch(_) {}

          n--;

}

Vamitul
VamitulCorrect answer
Legend
January 31, 2013

then, instead of myFrame.releaseAnchoredObject(); use myFrame.remove();