Copy link to clipboard
Copied
I know it can be done, but I'm not a programmer. What would be the script to duplicate a user defined number of pages after a user defined page in a mulit-page InDesign document? We have documents with up to 159 pages, but need to have pages within the documents duplicated right after a selected page, not to the end of the document.
This is all I have of a script for this and I don't know how to make it work or make it user-interactive for page number input:
--Duplicating more than one page at a time in InDesign CS4
tell application "Adobe InDesign CS4"
set mySourcePageNumber to UserInput1
set numberOfPages to UserInput2
tell application "InDesign 6.0.3"
tell active document
repeat numberOfPages times
set myNewPage to duplicate page mySourcePageNumber
end repeat
end tell
end tell
end tell
Copy link to clipboard
Copied
This is a very basic script, just written for you on CS3 and totally untested:
if (app.documents.length == 0){
alert ("Please open a document, select an object, and try again.");
exit();
}
var myDoc = app.activeDocument;
var myPage = myDoc.layoutWindows[0].activePage;
var myPageId = myPage.id;
var myDialog = app.dialogs.add({name:"Duplicate pages"});
with(myDialog.dialogColumns.add()){
with(borderPanels.add()){
staticTexts.add({staticLabel:"Duplicate front-most page # " + myPage.name});
var myIntBox = integerEditboxes.add({editValue:1, smallNudge:1, largeNudge:10});
staticTexts.add({staticLabel:" times"});
}
}
var myResult = myDialog.show();
if(myResult == true){
var myNumber = myIntBox.editValue;
if (myNumber < 1) {
alert(myNumber + " is invalid number.");
exit();
}
for (i = 0; i < myNumber; i++) {
myPage.duplicate(LocationOptions.AFTER, myDoc.pages.itemByID(myPageId));
}
}
myDialog.destroy();
It duplicates the active (the front-most page) — its number you see in the bottom left corner of the document window. You can type a number or use up/down arrows to increment it by 1 (add shift key to increment it by 10).
Hope it helps.
Kasyan
Copy link to clipboard
Copied
Thank you for your response. Is this Javascript? ScriptEditor is tagging errors, so I'm assuming it's possibly not a complete script...(Please forgive me...my ignorance is showing here...)
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks. I found my old "CreaText" program and was able to save it out as a javascript file. It works great! I'll work on tweaking it this weekend and see if I can get it to do the rest of what I need. Thank you so much for getting me pointed in the right direction!!!
Copy link to clipboard
Copied
You can use ExtendScript Toolkit to edit javascripts — it's preinstalled with InDesign. Check out your Applications/Utilites/Adobe Utilites/ExtendScript Toolkit CS4 folder.
Kasyan
Copy link to clipboard
Copied
Thank you. I can't do much here at work (where the script is needed) because the IT department has locked down the program areas. But I'll try it at home.
Do you have a good place to get more information on a non-programmer's guide to javascript? I can see what you did and understand it, but I can't seem to do what needs to be done by myself...and I want to learn how.
Copy link to clipboard
Copied
I recommend you to start from here: http://www.adobe.com/products/indesign/scripting/?promoid=DRHXE
Under Scripting resources section you will find Adobe Introduction to Scripting and Adobe InDesign CS4 Scripting Tutorial.
Kasyan
Copy link to clipboard
Copied
Thanks! I'll check it out! I appreciate your help.
Copy link to clipboard
Copied
Dear Kasyan ,
can i use your code to duplicate the whole pages or the main document with reversed order
Thanks in advance