Article View: adobe.scripting.indesign
Article #8226Re: Need Script for Page # of # (IDCS Windows)
From: Theresa_Verburg
Date: Wed, 25 Oct 2006 00:13
Date: Wed, 25 Oct 2006 00:13
37 lines
2900 bytes
2900 bytes
Hi Brenda:
I was given this script a while ago from someone on the forum here (I think it was Martin Fischer) and I use it ALL the time. It has been a great asset to our department for exactly the same reasons that you specified. I modified this script a bit to suit your needs and compensate for the 5 less pages that are included in the numbering system that you use. If you need to include all of the pages in the numbering, then just adjust the 2nd line to be "var myLastPage = myDoc.pages[-1].name;"
You will need to create a character style called "LastPageNum" (or whatever name you choose) and apply the character style to the whatever you use to indicate the last page number. (I use "XX")
Just a couple of tips: It's not necessary, but I find it very helpful to add the color red to the "LastPageNum" character style temporarily so it will jump out from the page at me. It's mostly so I don't forget to update it as the page count changes. I change it back to black before saving it. I also display the last page number as "Page 1 of XX pages". It's really hard to miss the red "XX" when you're giving your document a final review.
If your page count changes (add or delete pages), just re-run the script and it will update all of the numbers. It's really cool!!
//******************
var myDoc = app.activeDocument;
// If you are including all pages use "myDoc.pages[-1].name;"
var myLastPage = myDoc.pages[-6].name;
var myStyle = myDoc.characterStyles.item("LastPageNum");
//Clear out any existing preferences
app.findPreferences = app.changePreferences = null;
myDoc.search("",false,false,myLastPage,appliedCharacterStyle:myStyle});
//Clear out preferences again when finished
app.findPreferences = app.changePreferences = null;
//************
Save the text above to a text file and give it the ".js" extension if you are using CS1 and ".jsx" if you are using CS2. Save it in the folder named ...\Program Files\Adobe\Adobe InDesign CS (or CS2)\Presets\Scripts\.
To run the script, go to: Window > Automation > Scripts and double click the file name in the list.
I hope you will get as much use out of this script as I have. Be sure to thank Martin Fischer if this works for you. He was the real brains on this one.
Good Luck!
TJV
Technical Details
Message-ID:
<3bc1f61f.0@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.germany.com!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc1f61f.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,c7b49c49c6b60c6c X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Theresa_Verburg@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: Need Script for Page # of # (IDCS Windows) Message-ID: <3bc1f61f.0@webcrossing.la2eafNXanI> Date: Tue, 24 Oct 2006 17:13:21 -0700 References: <3bc1f61f.-1@webcrossing.la2eafNXanI> Lines: 59 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.germany.com!news.ecp.fr!news.stben.net!webcrossing