5 Replies Latest reply on Mar 27, 2014 2:38 AM by BEGINNER_X

    TOC parameter

    BEGINNER_X Level 3

      Hi Genius,

       

      Could anyone help how to save the TOC parameter in the variable that already defined in the active document.

       

      My request need to save the parameters for the following entries:

       

      1. Entry Style

       

      2. Page Number

       

      3. Between Entry and Number

       

      4. etc....

      Screen Shot 2014-03-26 at 12.33.09 PM.png

       

      Trying coding is below:

       

      //Working fine
      var myTocStyle = app.activeDocument.tocStyles.item(-1).name;
      alert("myTocStyle: " + myTocStyle)    
      
      var myTitleStyle = app.activeDocument.tocStyles.item(-1).titleStyle.name;
      alert("myTitleStyle: " + myTitleStyle)   
      
      //Not working 
      var myFormatStyle = app.activeDocument.tocStyleEntries.formatStyle.name;
      alert("myFormatStyle: " + myFormatStyle)
      
      var myPageNumber = app.activeDocument.tocStyleEntries.pageNumberPosition;
      alert("myPageNumber: " + myPageNumber)
      
      var mySeperator = app.activeDocument.tocStyleEntries.separator;
      alert("mySeperator: " + mySeperator)
      

       

       

      Please help for my urgent request.

       

      Thanks

      Beginner_X

        • 1. Re: TOC parameter
          Jump_Over Level 5

          Hi,

           

          1. TOCStyle is a parent for TOCStyleEntry (not document)

          2. TOCStyleEntries is a collection, so you can call a specific property for one of them, say tocStyleEntries[0] or tocStyleEntries.itemByName("FM_H1")

           

          In your example:

          var myPageNumber = myTocStyle.tocStyleEntries.itemByName("FM_H1").pageNumberPosition;
          

           

          Jarek

          1 person found this helpful
          • 2. Re: TOC parameter
            BEGINNER_X Level 3

            Hi Jump,

             

            Thanks for your immediate response...

             

            I tried your code, but it not works for me, may I did mistake, please clear my code

             

             

            var myTocStyle = app.activeDocument.tocStyles.item(-1).name;
            alert("myTocStyle: " + myTocStyle)
            
             //~ var myPageNumber = myTocStyle.tocStyleEntries.itemByName("FM_H1").pageNumberPosition;   //Jump_Over Code
            //~ var myPageNumber = myTocStyle.tocStyleEntries.item(0);
            alert("myPageNumber: " + myPageNumber)
            
            //~ var myEntryStyle = myTocStyle.tocStyleEntries.item(0).formatStyle.name;
            var myEntryStyle = myTocStyle.tocStyleEntries.formatStyle.name;
              
            alert("myEntryStyle: " + myEntryStyle)
            

             

            Output that I need is:

             

            As per my attachment, in above line (alert for myEntryStyle) should be "FM_H1" style. Then i got the output.

             

            Thanks in advance

            Beginner

            • 3. Re: TOC parameter
              Jump_Over Level 5

              Hi,

               

              Just to be sure if there are any entries:

               

              var mTOCStyle = app.activeDocument.tocStyles[-1];
              alert (mTOCStyle.tocStyleEntries.everyItem().name);
              

               

              Notice that your mTocStyle is a name (string);

              Notice that it can be no entries or - using names - it should be present.

               

              Jarek

              1 person found this helpful
              • 4. Re: TOC parameter
                Jump_Over Level 5

                Hi,

                 

                ...

                so you should start with lines like this:

                var myTocStyle = app.activeDocument.tocStyles[-1];
                alert("myTocStyle: " + myTocStyle.name);
                

                 

                Jarek

                • 5. Re: TOC parameter
                  BEGINNER_X Level 3

                  Hi Jump,

                   

                  Thanks a lot for your valuable timing!!!

                   

                  I got solution for my request with the help of your tips.

                   

                   

                  var myFormatStyle = app.activeDocument.tocStyles.item(-1).tocStyleEntries.item(0).formatStyle.name;
                  alert("myFormatStyle: " + myFormatStyle)
                  
                  var myPageNumberPosition = app.activeDocument.tocStyles.item(-1).tocStyleEntries.item(0).pageNumberPosition;
                  alert("myPageNumberPosition: " + myPageNumberPosition)
                  
                  var mySeparator = app.activeDocument.tocStyles.item(-1).tocStyleEntries.item(0).separator;
                  alert("mySeparator: " + mySeparator)
                  

                   

                   

                  Again thanks a lot.

                   

                  Thanks

                  Beginner