Sometimes, even the simpliest tasks looks unfeasible !
I want to send text content from a doc1 to a doc2. So let's say both document have a container with a same label "here".
What is the best option to get contents from the labeled "here" textframe on doc1 to doc2 ? I tried copy/paste but as I do this operation in a loop, it's like app.select() is just helpless (throwing error while it works outside of a loop !). I tried textframe.texts.everyItem().duplicate() but I can't pass it doc2 targeted textframe as the destination.
and of course using contents=contents is helpless as the operation discards any styles applied.
So any hint will be helpful.
Here is my way of doing this:
var doc1 = app.documents.item("Doc1.indd"); var doc2 = app.documents.item("Doc2.indd"); var tf1 = doc1.textFrames.item("here"); var tf2 = doc2.textFrames.item("here"); tf1.texts.duplicate(LocationOptions.AFTER, tf2.texts);
You can use move instead of duplicate to move text.
Thanks so much Kasyan,
I was so close ! I was using
tf2.insertionPoints instead of
I should slap myself.
Thanks again and Merry Christmas/Happy New Year to all of you folks