Copy link to clipboard
Copied
Several years ago, someone here (I think Dave, maybe Ole) helped me out by giving me a short script that when run added a blank page (with a specified master page different from the previous page) after each page of a document.
I've had an emergency reformat of my system and have lost that script which I need constantly for work projects. I tried searching here, but it was before the current forum setup (I think around 2 years ago) and I can't find a way to get to the archives.
If anyone can either provide me with the java script code for this or point me to the old messages about it, I'd be very appreciative.
And, BTW, I am now using CS4 (though I'm sure the script I've been using was from an older version).
Thank you.
1 Correct answer
Here: I don't know about the original, but I just whipped this together for you:
...var doc = app.documents[0];
var masterNames = doc.masterSpreads.everyItem().name;
var d = app.dialogs.add({name:"pick a master spread"});
d.dialogColumns.add().staticTexts.add({staticLabel:"Master Pages:"});
var dd = d.dialogColumns.add().dropdowns.add({stringList:masterNames});
if(d.show()){
var index = dd.selectedIndex;
d.destroy();
} else {
d.destroy();exit();
}
var master = doc.masterSpreads.item(index);
for(v
Copy link to clipboard
Copied
I have located the old PageMaker scripts that I had used for this purpose. If it will help anyone to post them, please let me know and I will do so.
Copy link to clipboard
Copied
Aaahhh ... PageMaker scripting. Now there was a challenge -- I don't think I ever could write the thing I intended with that.
This quick javascript works on CS, but I don't think the syntax has changed (much) for CS4. Yell if it doesn't work.
Be sure to fill in the right 'blank page' name in the first line! That includes the prefix and the hyphen -- the script will alert you if you got it wrong
//DESCRIPTION: Add Blank Master Page after each page
masterPageName = "A-AddMe";
masterPage = app.activeDocument.masterSpreads.item(masterPageName);
if (masterPage == null)
{
alert ('"'+masterPageName+'" is not a valid master...');
exit(0);
}// Start at the end:
currentPage = app.activeDocument.pages.length-1;
while (currentPage >= 0)
{
theNewPage = app.activeDocument.pages.add (LocationOptions.AFTER, app.activeDocument.pages[currentPage]);
theNewPage.appliedMaster = masterPage;
currentPage--;
}
Copy, paste into a plain text editor (InDesign's ESTK is good) and save as "insertBlanksAfterAll.jsx" in your Scripts folder. When saved in the right folder, it will automatically become available in the Scripts Panel.
Copy link to clipboard
Copied
Jong:
Too slow...
Harbs
Copy link to clipboard
Copied
Thank you very much. I tried it, but it didn't work (I changed the
masterPageName variable in the first line to D-Back which is the name of the
master page I want to use).
Upon running I got an error that
JavaScript Error!
Error Number:2
Error String: masterPage is undefined
...
...
Line 2:
Source: if (masterPage == null)
Perhaps it is because my original pages are based on a different specified
Thanks, but please don't waste more time on this as Harbs has given me a
working script.
Copy link to clipboard
Copied
.. it didn't work ..
Ouch! It must be one of "those things" that did change (and I bet it does work if you change 'null' in that erronous line to "undefined", which is another way of saying it's nothing at all.)
Congrats, Gabe .. until next time! (Ha Ha Ha etc.)
Copy link to clipboard
Copied
[Jongware] wrote:
Ouch! It must be one of "those things" that did change (and I bet it does work if you change 'null' in that erronous line to "undefined", which is another way of saying it's nothing at all.)
It was probably a copy-paste error. (Note the bit about line 2 -- which should be line 3 or 4...)
Congrats, Gabe .. until next time! (Ha Ha Ha etc.)
Hey Jong, that's "Harbs" among friends... (Or should I call you Theus.)
Harbs
Copy link to clipboard
Copied
http://forums.adobe.com/message/2306710#2306710
Peter
Copy link to clipboard
Copied
Yeah, but they're both Theus (Teus?)!
Get's really confusing!
Copy link to clipboard
Copied
No, no -- one is Teus and the other is, well, not.
Copy link to clipboard
Copied
Jong's got a different story...
http://forums.adobe.com/message/2127386#2127386
Harbs
Copy link to clipboard
Copied
Harbs was indeed wrong, fusing two possible short forms -- it's "Theun" (but for friends only!).
I can't believe you are throwing old threads at eachother, trying to work it out ... Stop arguing, you are confusing me and everyone else!
Copy link to clipboard
Copied
> I can't believe you are throwing old threads at each other
They don't hurt!
Copy link to clipboard
Copied
Well, do I count as a friend?
Harbs
Copy link to clipboard
Copied
I include everyone posting on these forums as my friends.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Here: I don't know about the original, but I just whipped this together for you:
var doc = app.documents[0];
var masterNames = doc.masterSpreads.everyItem().name;
var d = app.dialogs.add({name:"pick a master spread"});
d.dialogColumns.add().staticTexts.add({staticLabel:"Master Pages:"});
var dd = d.dialogColumns.add().dropdowns.add({stringList:masterNames});
if(d.show()){
var index = dd.selectedIndex;
d.destroy();
} else {
d.destroy();exit();
}
var master = doc.masterSpreads.item(index);
for(var i=doc.pages.length-1;i>=0;i--){
doc.pages.add(LocationOptions.AFTER,doc.pages,{appliedMaster:master});
}
HTH,
Harbs
Copy link to clipboard
Copied
Oh, sure, it has a dialog, but ...
Hm -- seems to work exactly as mine.
.. Oh well.
Copy link to clipboard
Copied
Thank you so, so much -- it works perfectly. I appreciate your time and
help.
Copy link to clipboard
Copied
He he -- who, Harbs or me? He offers a dialog; mine can run unattended (well, after filling in the master page name). Remember, 10 points for the winner, 5 for helpful answers. (Oooh -- pick me! pick me! Unless Harbs wants to say something first.)
Copy link to clipboard
Copied
Oh Come on Jong, you have WAY more points than me! Give to the poor...
Harbs

