JavaScript for continuously numbering documents

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / JavaScript for continuously numbering documents

Viewing 21 reply threads
  • Author
    Posts
    • #1236563
      Edward Randell
      Participant

      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?

    • #1236574
      Peter Kahrel
      Participant

      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

    • #1236714
      Edward Randell
      Participant

      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

    • #1236924
      Edward Randell
      Participant

      Peter – After I run the script, should I save the documents when I close them, or close them without saving them?

    • #1236934
      Edward Randell
      Participant

      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.

    • #1236964
      Peter Kahrel
      Participant

      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!

    • #1236974
      Edward Randell
      Participant

      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.

    • #1236984
      Peter Kahrel
      Participant

      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.

    • #1236994
      Peter Kahrel
      Participant

      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.

    • #12370244
      Edward Randell
      Participant

      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.

    • #12370444
      Peter Kahrel
      Participant

      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?

    • #12370544
      Edward Randell
      Participant

      I don’t have a script to change to automatic numbering.

    • #12371844
      Peter Kahrel
      Participant

      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.

    • #12372244
      Edward Randell
      Participant

      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.

    • #1237274
      Peter Kahrel
      Participant

      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.

    • #12372744
      Peter Kahrel
      Participant

      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.

    • #12373344
      Edward Randell
      Participant

      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.

    • #1237334
      Edward Randell
      Participant

      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.

    • #1237745
      Peter Kahrel
      Participant

      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.

    • #1237784
      Edward Randell
      Participant

      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.

    • #1237824
      Edward Randell
      Participant

      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!

    • #1237884
      Peter Kahrel
      Participant

      Excellent!

Viewing 21 reply threads
  • You must be logged in to reply to this topic.
>