2 Replies Latest reply on Jan 18, 2017 8:35 AM by Julia.McG

    Update TOC from the Book Pane

    oneoff_swe

      I have at least eight .indd documents in a book, six of these contain an individual TOC.

       

      Do you know an available script that I can execute which automatically updates all TOCs? I don't want to manually open all documents in the book and select Layout --> Update Table of Content?

       


      My original thread in the Indesign forum: https://forums.adobe.com/message/6629166#6629166

        • 1. Re: Update TOC from the Book Pane
          Sajeev Sridharan Level 4

          The below script will take some time, but it will accomplish your wish.

           

          myBookFile = File.openDialog("Choose the BOOK File", "INDB:*.indb", false);
          app.open(File(myBookFile.fullName.toString()));
          var myBook = app.activeBook;
          
          
          for(var n=0; n < myBook.bookContents.length; n++)
          {
              app.open(File(myBook.bookContents[n].fullName.toString()));
              for (var i = 0; i < app.activeDocument.allPageItems.length; i++)
              {
                  var myPageItem = document.allPageItems[i];
                  if(myPageItem.getElements()[0].constructor.name == "TextFrame")
                  {
                      myPageItem.select();
                      try{
                          app.scriptMenuActions.itemByID(71442).invoke();
                      }catch(e){}
                  }
              }
              app.activeDocument.close(SaveOptions.YES);
          }
          app.activeBook.close(SaveOptions.YES);
          

           

           

          Vandy

          • 2. Re: Update TOC from the Book Pane
            Julia.McG

            I tried this script and was so hopeful. It was not successful for me. Are there any manual edits that one would need to make in order for this to work with a particular book? For example, I deleted the step numbers...that eliminated one error. But it still isolates problems with the content in line 2. Any suggestions?