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

Need script to insert pages with specified master

Engaged ,
Oct 12, 2009 Oct 12, 2009

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.

TOPICS
Scripting
8.0K
Translate
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

LEGEND , Oct 12, 2009 Oct 12, 2009

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

...
Translate
Engaged ,
Oct 12, 2009 Oct 12, 2009

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.

Translate
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 ,
Oct 12, 2009 Oct 12, 2009

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.

Translate
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
LEGEND ,
Oct 12, 2009 Oct 12, 2009

Jong:

Too slow...

Harbs

Translate
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
Engaged ,
Oct 12, 2009 Oct 12, 2009

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

master, not on ?

Thanks, but please don't waste more time on this as Harbs has given me a

working script.

Translate
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 ,
Oct 12, 2009 Oct 12, 2009
.. 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.)

Translate
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
LEGEND ,
Oct 12, 2009 Oct 12, 2009

[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

Translate
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 ,
Oct 12, 2009 Oct 12, 2009

http://forums.adobe.com/message/2306710#2306710

Peter

Translate
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
LEGEND ,
Oct 12, 2009 Oct 12, 2009

Yeah, but they're both Theus (Teus?)!

Get's really confusing!

Translate
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 ,
Oct 12, 2009 Oct 12, 2009

No, no -- one is Teus and the other is, well, not.

Translate
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
LEGEND ,
Oct 13, 2009 Oct 13, 2009

Jong's got a different story...

http://forums.adobe.com/message/2127386#2127386

Harbs

Translate
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 ,
Oct 13, 2009 Oct 13, 2009

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!

Translate
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 ,
Oct 13, 2009 Oct 13, 2009

> I can't believe you are throwing old threads at each other

They don't hurt!

Translate
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
LEGEND ,
Oct 13, 2009 Oct 13, 2009

Well, do I count as a friend?

Harbs

Translate
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 ,
Oct 13, 2009 Oct 13, 2009

I include everyone posting on these forums as my friends.

  • Being a typophile as well doubles your word value.
  • But I pointedly exclude anyone publishing my HTML help files without the appropriate acknowledgements. Yes, you know who you are. (तुम्हें पता है कि तुम कौन हो! / 你知道你是誰!)
  • Translate
    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
    LEGEND ,
    Oct 13, 2009 Oct 13, 2009
    LATEST

    [Jongware] wrote:

    I include everyone posting on these forums as my friends.

  • Being a typophile as well doubles your word value.
  • Oh goody!

    Does saying that I always have your Object Model open in a tab in my browser give me triple scoring?

    Harbs

    Translate
    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
    LEGEND ,
    Oct 12, 2009 Oct 12, 2009

    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

    Translate
    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 ,
    Oct 12, 2009 Oct 12, 2009

    Oh, sure, it has a dialog, but ...

    Hm -- seems to work exactly as mine.

    .. Oh well.

    Translate
    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
    Engaged ,
    Oct 12, 2009 Oct 12, 2009

    Thank you so, so much -- it works perfectly. I appreciate your time and

    help.

    Translate
    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 ,
    Oct 12, 2009 Oct 12, 2009

    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.)

    Translate
    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
    LEGEND ,
    Oct 12, 2009 Oct 12, 2009

    Oh Come on Jong, you have WAY more points than me! Give to the poor...

    Harbs

    Translate
    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