1 Reply Latest reply on Aug 20, 2016 8:14 PM by selvam214

    two way hyperlink with another document (destination doc)

    selvam214 Level 1

      Hi All,

      I trying to create the two way hyperlink to current or another document. Can you please guide to me how to achieve my target.

       

       

      This is current document two way links successfully done (below code). Please guide to me, how to link another document also?

       

       

      //roman number is current document, arabic number is another document

      var myInput = ["xix:Preface for Instructors:v", "xix:Introduction for Writers:xv", "xix:Understanding the Technical Communication Environment:1"];//input variable

      for(var s=0; s<myInput.length; s++){//travel based on input length

          var array = myInput[s].split(":");//split the first array

          var myInput1 = array[0]; //content page number

          var myInput2 = array[1];//content text

          var myInput3 = array[2];//hyperlink destination page number

          app.findGrepPreferences = app.changeGrepPreferences = null;

          app.findChangeGrepOptions.includeMasterPages = false;

          app.findGrepPreferences.findWhat = myInput2;

          var myFound1 = app.activeDocument.findGrep();

          for(var g=0; g<myFound1.length; g++){

              var myPage=myFound1[g].parentTextFrames[0].parentPage.name;

              if(myInput1==myPage){//match the page number

                  var myselect = myFound1[g].select();

                  var myPage = app.activeDocument.pages.item(myInput3);

                  var mytext = app.selection[0];

                  var myDest = HyperlinkPageDestination.destinationPage = myPage;

                  var myHyperlinkSource = app.activeDocument.hyperlinkTextSources.add(mytext);

                  var myHyperlinkURLDestination = app.activeDocument.hyperlinkPageDestinations.add(myDest);

                  var myHyperlink = app.activeDocument.hyperlinks.add(myHyperlinkSource, myHyperlinkURLDestination);

                  }

              if(myInput3==myPage){//reverse link

                  var myselect = myFound1[g].select();

                  var myPage = app.activeDocument.pages.item(myInput1);

                  var mytext = app.selection[0];

                  var myDest = HyperlinkPageDestination.destinationPage = myPage;

                  var myHyperlinkSource = app.activeDocument.hyperlinkTextSources.add(mytext);

                  var myHyperlinkURLDestination = app.activeDocument.hyperlinkPageDestinations.add(myDest);

                  var myHyperlink = app.activeDocument.hyperlinks.add(myHyperlinkSource, myHyperlinkURLDestination);

                  }

              }

          }

      //end the code

       

      Additionally, the documents concept,

       

      for(var dcn = 0; dcn < app.documents.length; dcn++){

          var document = app.documents[dcn];

          var mypages = document.pages;

          for(var p=0; p<mypages.length; p++){

              if(mypages[p].name==2){

                  var mydocname = document.name;

                  }

              }

          }

       

      //but I can't go to next step.

       

       

      Thanks in advance,

      Selva