Skip to main content
Inspiring
October 13, 2011
Answered

how to paste a text in a selected textframe

  • October 13, 2011
  • 1 reply
  • 692 views

Hi, for a new script I would like to paste some text in a textFrame.

I would like to select my text, copy it and run my script.

My script locate a textframe, select it.

I don't know how to paste in the content of the selected textframe.

app.paste();

Paste is OK, but it create a new textframe while the block is well selected.

Can you help me?

thx!

This topic has been closed for replies.
Correct answer Jongware

So it works the same as it does in the interface itself. Try it: copy text, select (but do not enter) a text frame, hit Paste. A new text frame appears.

To get what you want, you need to put the text cursor inside your selected frame. That's not a function but fortunately this weird-looking command works:

app.selection[0].insertionPoints[-1].select();

app.paste();

1 reply

Jongware
Community Expert
JongwareCommunity ExpertCorrect answer
Community Expert
October 13, 2011

So it works the same as it does in the interface itself. Try it: copy text, select (but do not enter) a text frame, hit Paste. A new text frame appears.

To get what you want, you need to put the text cursor inside your selected frame. That's not a function but fortunately this weird-looking command works:

app.selection[0].insertionPoints[-1].select();

app.paste();

seba1395Author
Inspiring
October 14, 2011

Very nice! Thx