• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Copy/paste scripting

Participant ,
Jun 23, 2024 Jun 23, 2024

Copy link to clipboard

Copied

"Can I copy an object and paste it into all pages in the same position as if I pressed Ctrl+Shift+Alt+V using a script? Could someone please provide the code?"

TOPICS
How to , Performance , Scripting , SDK , Type

Views

159

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 24, 2024 Jun 24, 2024

Hi @aghanjar16430960 , Also, a script can duplicate a selected page item and skip the copy and paste. Something like this:

 

 

//a selected object
var s = app.activeDocument.selection[0]

var pg = app.activeDocument.pages.everyItem().getElements()
for (var i = 0; i < pg.length; i++){
    s.duplicate(pg[i])
}

 

 

Screen Shot 4.png

 

Screen Shot 3.png

Votes

Translate

Translate
Community Expert ,
Jun 23, 2024 Jun 23, 2024

Copy link to clipboard

Copied

Yes. 

 

If your document is a single page per Spread then you can iterate through Pages collection and just use app.pasteInPlace().

 

If multiple pages per Spread - then after initial app.pasteInPlace() you'll have to move horizontally by the width of the page - positive or negative - depends on from which page you've copied it from. 

 

Of course you need to take into consideration if all pages have the same width and orientation, etc. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2024 Jun 24, 2024

Copy link to clipboard

Copied

Hi @aghanjar16430960 , Also, a script can duplicate a selected page item and skip the copy and paste. Something like this:

 

 

//a selected object
var s = app.activeDocument.selection[0]

var pg = app.activeDocument.pages.everyItem().getElements()
for (var i = 0; i < pg.length; i++){
    s.duplicate(pg[i])
}

 

 

Screen Shot 4.png

 

Screen Shot 3.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 26, 2024 Jun 26, 2024

Copy link to clipboard

Copied

LATEST

thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines