3 Replies Latest reply on Aug 29, 2017 12:20 AM by s.vnesh

    createTOC error

    IM_01 Level 1

      Hi all!!


      I am working with InDesign server CS3. In my script I'm having problems calling to the function createTOC().


      This is my code:


      var estiloTOC = app.documents.firstItem().tocStyles.itemByName("EstiloTOC1");



      The error only says javascript error in the function createTOC.


      I try de same code in the InDesign CS3 desktop version and it works.

        • 1. Re: createTOC error
          A.Held Level 1

          Hi IM_01,


          test this example Script. I'm write and testing this Script on ID Server CS4. works fine. I hope it help you.


          // It must be opened a document. Also a document can be created.
          var myDocument = app.documents.item(0);
          //If the TOC Style "myToc" does not already exist, create it.
          // Importent: Try and Catch

              myTocStyle = myDocument.tocStyles.item("myToc");
          catch (myError){
                  myTocStyle = myDocument.tocStyles.add();
                  myTocStyle.name = "myToc";
              createBookmarks = true;
              includeBookDocuments = true;
              label = "myLabel";
              title = "myTitle";

              // Enter more Properties

          1 person found this helpful
          • 2. Re: createTOC error
            IM_01 Level 1

            Thanks for your help Andreas!!


            I've just found the solution to my problem.


            When you are editing your InDesign template from InDesign Desktop, and close the document with a master spread as the active page, the next time that you open the document from InDesign Server (app.open(File("c:\Template.indt"))) the active page by default would be a master spread, so we'll have problems when we try to place the Table of Contents from our script in the IndDesign Server.


            By the moment the solution consist in always leave open the first page of the template before save & close it.



            • 3. Re: createTOC error

              Excellent nice catch