3 Replies Latest reply on Sep 17, 2009 8:04 AM by ivan888

    Cross-reference destination




      I would like to set destination for cross-reference to paragraph style like I do when I click on cross-reference options. On options screen I have a list of paragraph styles, but I don't get how to do that in script(JS).



        • 1. Re: Cross-reference destination
          ivan888 Level 1

          I came to conclusion that every crossreference has a hyperlink, and hyperlink has a destination. What I don't understand is how to make hyperlink's destinatio from paragraph style...

          • 2. Re: Cross-reference destination
            Peter Kahrel Adobe Community Professional & MVP

            > I came to conclusion that every crossreference has a hyperlink


            Correct. For an example, see http://www.kahrel.plus.com/indesign/foot_to_end.jsx. The script uses cross-references to convert InDesign's footnotes to automatically numbered endnotes



            • 3. Re: Cross-reference destination
              ivan888 Level 1

              I finnaly achieved what I wanted. I did it in stupidest possible way, but it works. I iterated through all paragraphs and than if that paragraph had style that i was searching for I linked it with corss reference. Here is my code for 3 crossreferences I had to re-link:


              var mydoc = app.documents.item(0);
              for (var i=0; i<mydoc.textFrames.length; ++i) {
                   var frame = mydoc.textFrames.item(i);
                   for (var j=0; j<frame.paragraphs.length; ++j) {
                        var ap=frame.paragraphs.item(j);
                        if (ap.appliedParagraphStyle.name == "Highlight_p") {
                             // One
                             mydoc.hyperlinks.item("Cross-Reference").destination = mydoc.hyperlinkTextDestinations.add(ap);
                        } else if ( ap.appliedParagraphStyle.name == "Highlight" ) {
                             // Two
                             mydoc.hyperlinks.item("Cross-Reference 1").destination = mydoc.hyperlinkTextDestinations.add(ap);
                        } else if (ap.appliedParagraphStyle.name == "Highlight_o") {
                             // Three
                             mydoc.hyperlinks.item("Cross-Reference 2").destination = mydoc.hyperlinkTextDestinations.add(ap);

              EDIT: I hope someone will find this usefull