3 Replies Latest reply: Sep 21, 2010 7:50 AM by [Jongware] RSS

    How to access the Index topics?

    Praveen10 Community Member

      Hi,

       

      I need to get the already available index topics from InDesign CS3, and to update 'Sort by' option for some entries. Can anyone pl. help?

       

      Thanks,

       

      Praveen

        • 1. Re: How to access the Index topics?
          [Jongware] Community Member

          What have you got, so far?

          • 2. Re: How to access the Index topics?
            Praveen10 Community Member

            I've tried with below coding, it's showing like 'Undefined is not an object':

             

            var myDoc = app.activeDocument;

            var myIndex = myDoc.indexes[0];

            var myTopic = myIndex.topics;

            alert(myTopic.length);

             

            Thanks,

             

            Praveen

            • 3. Re: How to access the Index topics?
              [Jongware] Community Member

              Hmmm. So first thing to find out is what line fails.

               

              var myDoc = app.activeDocument;

              if (myDoc.indexes.length != 0)          // Do we have any index at all? If not, no point in trying.

              {
                var myIndex = myDoc.indexes[0];

                var myTopic = myIndex.topics;

                alert(myTopic.length);

              }

               

              Now hold on -- this fails when there is no index at all, but if I add even a single topic, it correctly shows "1" for myTopic.length. Are you sure you are trying on a file with an actual index?

              This line at the end

               

              alert(myTopic.everyItem().name.join("\r"));

              correctly shows a list of every topic in the index.