Skip to main content
Inspiring
January 6, 2017
Answered

How to select and copy

  • January 6, 2017
  • 4 replies
  • 659 views

Hi experts,

Assume my active doc has only one story, my goal is to select the text and copy.

How I can do that?

my script like this:

var mySource = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();

       mySource.select();

app.copy();

but not working.

Could someone show me how please.

thanks

Regard

John

This topic has been closed for replies.
Correct answer Laubender

Hi John,

if your document contains only one single story use just that story and its texts property:

var doc = app.documents[0];

var story = doc.stories[0];

doc.select(story.texts[0]);

app.copy();

EDIT:

You cannot select the text of several stories at one time.

InDesign is not able to do that.

Regards,
Uwe

4 replies

JohnwhiteAuthor
Inspiring
January 7, 2017

thank you Wue

thank so much.

Regard

John

JohnwhiteAuthor
Inspiring
January 7, 2017

thank you guys

thank you so much.

regard

John

Community Expert
January 7, 2017

Hi John,

what do you like to do with the copied story?

Story objects do have a duplicate() method:

Adobe InDesign CS6 (8.0) Object Model JS: Story

Regards,
Uwe

LaubenderCommunity ExpertCorrect answer
Community Expert
January 7, 2017

Hi John,

if your document contains only one single story use just that story and its texts property:

var doc = app.documents[0];

var story = doc.stories[0];

doc.select(story.texts[0]);

app.copy();

EDIT:

You cannot select the text of several stories at one time.

InDesign is not able to do that.

Regards,
Uwe

January 7, 2017

var mySource = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements(); 

for(var i=0; i<mySource.length; i++)   

{   

    mySource.select() 

   

//~      app.cut() 

//~      app.paste()  

}