JavaScript for continuously numbering documents
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / JavaScript for continuously numbering documents
- This topic has 21 replies, 2 voices, and was last updated 4 years ago by Edward Randell.
-
AuthorPosts
-
-
April 4, 2020 at 5:56 pm #1236563Edward RandellParticipant
In Issue 132 of InDesign Magazine is a wonderful article about JavaScript for InDesign. On page 34 is a list of SIMPLE SCRIPTS TO GET YOU STARTED. Script no. two is just what I need to continuously number all the chapter documents in my 16 chapter book. However I can’t get it to work.
Anyone else have this problem? -
April 5, 2020 at 3:24 am #1236574Peter KahrelParticipant
Edward — In what way can you not get it to work? What have you tried? Do you see an error message? Does something happen but not what you expected? Does nothing happen at all? The script works on the first section of every open document. To target all sections in a single document, do this:
app.documents[0].sections.everyItem().continueNumbering = true;
And you could even target all sections in all open documents:
app.documents.everyItem().sections.everyItem().continueNumbering = true;
And, finally, in case you want to open all documents in a book, here’s another one-liner:
app.open (app.activeBook.bookContents.everyItem().fullName);
There are many one-liners!
Peter
-
April 5, 2020 at 1:52 pm #1236714Edward RandellParticipant
Peter —Thank you for your response. I am going to try the script again (in case I didn’t do it properly the first time). I will have more accurate feedback then. Thanks again
Edward -
April 6, 2020 at 9:04 am #1236924Edward RandellParticipant
Peter – After I run the script, should I save the documents when I close them, or close them without saving them?
-
April 6, 2020 at 9:53 am #1236934Edward RandellParticipant
Peter – When I run the Continuous Numbering script, nothing changes in the documents and nothing changes in the Book dialogue box. All the docs begin numbering with one. Same thing after I close only and nothing changes after saving either.
PS The open all documents in the book script works fine. The close all documents works fine and the save only script appears to work properly. -
April 7, 2020 at 2:50 am #1236964Peter KahrelParticipant
I think I understand the problem: you need to enable the book’s automatic page numbering: in the book’s fly-out menu (click the three small horizontal lines at the top-right of the book panel), select Book Page Numbering Options and check the automatic page numbering. That should do the trick.
I could add that as a second line to the script, but then it would no longer be a one-liner!
-
April 7, 2020 at 4:35 am #1236974Edward RandellParticipant
Well, I’m sorry Peter, but Automatic Page Numbering in the book dialogue box was already checked before I ran my test. I tried it again just to be sure and nothing happens to the page numbers.
-
April 7, 2020 at 6:32 am #1236984Peter KahrelParticipant
Strange. After running the script, when you go to a document’s Numbering & Section Options window, which button is selected? ‘Automatic Page Numbering’ or ‘Start Page Numbering at’? Please check more than one document.
-
April 7, 2020 at 6:40 am #1236994Peter KahrelParticipant
By the way, Edward, coming back to your earlier query about saving documents: the script only changes the setting in the Numbering & Section Options window, nothing else. You need to save all the documents yourself.
P.
-
April 7, 2020 at 8:06 am #12370244Edward RandellParticipant
I checked the Numbering & Section Options settings on all six documents involved in my test. Each one has ‘Automatic Page Numbering’ selected. However in the ‘Start Page Numbering at’ option (even though it’s not selected) there is a page number highlighted in blue (as if selected). When I ran my test I just ignored these numbers. The ‘Start’ numbers are consecutive for the first three documents while the remaining document numbers refer the the number of pages in the previous document (non consecutive within the book).
Thank you for the tip about saving the scripted documents. -
April 7, 2020 at 12:48 pm #12370444Peter KahrelParticipant
One last thing you can try: use the script to change the document to automatic numbering, and save all the documents. Then in the book panel’s flyout, select Update Numbering, then All Numbers (or Update Page and Section Numbers, whichever you prefer). Does that work?
-
April 7, 2020 at 1:14 pm #12370544Edward RandellParticipant
I don’t have a script to change to automatic numbering.
-
April 8, 2020 at 2:14 am #12371844Peter KahrelParticipant
But the one you’ve been using changes the documents to number automatically… You are using this one, correct?
app.documents.everyItem().sections[0].continueNumbering = true;
And it’s the page numbers that should be targeted, not any other type of numbering — correct?
P.
-
April 8, 2020 at 8:06 am #12372244Edward RandellParticipant
Correct on both accounts. That’s the one I’m using.
I opened the book. I opened the documents. I ran the Continuous Numbering script. I saved all the documents. I did Update Numbering: All Numbers in the book’s flyout.
But still nothing happens to the document page numbers or the page numbers in the document list in the book dialogue box.
Thank you for barring with me. Maybe I have a corruption somewhere.
I will try this on my wife’s iMac. -
April 9, 2020 at 4:52 am #1237274Peter KahrelParticipant
I can’t imagine that corruption plays a role. If any of your documents were corrupt, InDesign wouldn’t be able to open it or if it did, would probably crash.
If you zip up your files and send then to [email protected] I’ll have a look.
P.
-
April 9, 2020 at 4:52 am #12372744Peter KahrelParticipant
I can’t imagine that corruption plays a role. If any of your documents were corrupt, InDesign wouldn’t be able to open it or if it did, would probably crash.
If you zip up your files and send then to [email protected] I’ll have a look.
P.
-
April 9, 2020 at 9:01 am #12373344Edward RandellParticipant
Peter-The zip file was too big to email so I sent it to you with WeTransfer. The file has all the chapters, photos, and fonts in case you need them.
-
April 9, 2020 at 9:01 am #1237334Edward RandellParticipant
Peter-The zip file was too big to email so I sent it to you with WeTransfer. The file has all the chapters, photos, and fonts in case you need them.
-
April 11, 2020 at 3:57 am #1237745Peter KahrelParticipant
File received in good order, thank you. After I opened the book and all its documents (apart from the first two, which shouldn’t change) I ran the one-line script and all documents were renumbered correctly. I’ll send a screenshot of the before and after books to your email, I can’t attach it here. You did you open the documents, did you not?
P.
-
April 11, 2020 at 12:12 pm #1237784Edward RandellParticipant
Peter – Thank you for your diligence in pursuing my situation to the end. I really appreciate your help. I feel that we left no stone unturned. – Next, I will try the experiment on my wife’s computer to see if the problem is unique to mine. – I’m looking forward to reading your book when it arrives. Thanks again.
-
April 11, 2020 at 1:53 pm #1237824Edward RandellParticipant
Peter – I am happy to report that I solved my problem! Through the Adobe Support Community I discovered that reseting InDesign’s preferences file might help. So I did that and the renumbering script works like a charm! Hurray!
-
April 13, 2020 at 2:39 am #1237884Peter KahrelParticipant
Excellent!
-
-
AuthorPosts
- You must be logged in to reply to this topic.