If you want to copy text contents, you don't have to mess around with its containing frame. Use myTextFrame.texts and the Text Duplicate or Move method (http://jongware.mit.edu/idcsjs5.5/pc_Text.html).
Don't worry about the plural and index number of "texts" -- I believe this is more of a side-effect of the programming model (and it has been left that way to prevent having to code multiple workarounds for such a minor issue), rather than that anticipating that somewhere in the future it's going to be possible to have "more than one Text" per frame.
1 person found this helpful
Just to expand on Jongwares answer with a of practical example.
To copy selected text of to a different text frame or to copy entire contents of the text frame were the cursor is see bellow script.
Look at the reference that Jongware provided for other location options
myDoc = app.activeDocument; myText=app.selection; // Copies selected text DELETE THE LINE BELOW IF YOU WANT TO DO THIS!! myText=app.selection.parentTextFrames.texts; // Copies entire text frame contents. myPage = myDoc.pages.add(); myTextFrame = myPage.textFrames.add(); myTextFrame.geometricBounds = [8, 8, 800, 200]; // Copies to new text frame (to move to new text frame use the move instead of duplicated i.e. myText.move(LocationOptions.AFTER,myTextFrame.insertionPoints) ; myCopy =myText.duplicate(LocationOptions.AFTER,myTextFrame.insertionPoints) ;
If you have an old version of indesign (no idea which) you might have to go with this approach.
Thanks for the input. I ended up traversing up to the top parentStory and then copying the paragraphs, as the other methods did not seem to work to well with linked text boxes.
here is what I have - which seems to work for me.
Assuming sourceTextFrame and destTextFrame are the textFrames you want to copy the content from......
var theSourceFrame = sourceTextFrame;
var parentSourceStory = sourceTextFrame.parentStory;
parentSourceStory.paragraphs.everyItem().duplicate(LocationOptions.after, destTextFrame.insertionPoints );
Hi D Jon Simcox
Why don't you use
parentSourceStory.duplicate(LocationOptions.after, destTextFrame.insertionPoints );
Without using "paragraphs.everyItem()" ?
Don't see that its needed.
you are absolutely right - thanks
past ? : end of last page & end of a paragraph