2 Replies Latest reply on Mar 22, 2010 2:14 AM by IM_01

    createTOC error

    IM_01

      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");

      app.documents.firstItem().createTOC(estiloTOC);

       

      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

          try{
              myTocStyle = myDocument.tocStyles.item("myToc");
              myTocStyle.name;
          }
          catch (myError){
                  myTocStyle = myDocument.tocStyles.add();
                  myTocStyle.name = "myToc";
          }
          with(myTocStyle){
              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.

             

            regards!!