2 Replies Latest reply on Oct 21, 2013 11:54 AM by McShaman

    Broken hyperlink crashing script

    McShaman Level 1

      I have been writing a script which helps manage hyerlinks. I am having a small issue where broken links are causing cause it to crash.

       

      Can sombody please confirm the following problem and please please please help me with a fix?

       

      • Create two new documents
      • In document 1 create a textbox and insert a New Hyperlink Destination
      • Save document 1 on the desktop
      • In document 2 create a textbox, write some text and make it a hyperlink linking to the text destination in documnet 1
      • Close document 1 and then move it to the trash
      • With document 2 active the links pannel should now show a red cirle with a question mark in it next to the link

       

      Now in a script try the following two lines of code (one at a time):

       

      return app.activeDocument.hyperlinks[0].destination;

       

      return typeof app.activeDocument.hyperlinks[0].destination;

       

      Both these return the following error:

       

      Hyperlink destination document not found. Please verify the document's location in the Hyperlinks panel before choosing this hyperlink.

       

      In the Data Browser, unlike normal hyperlinks, these broken hyperlinks don't look to have a destination property... But I cant test to see if that property exists because it keeps through this damn error!

       

      Please help!!

        • 1. Re: Broken hyperlink crashing script
          ping rajesh

          Hi,

           

          You can use "hyperlinkExternalPageDestination" to achieve this.

           

          For e.g.

           

          app.activeDocument.hyperlinkExternalPageDestinations.add(app.documents.item(1).textFrames[0].parentPage);
          

           

          Thanks,

          ping rajesh

          • 2. Re: Broken hyperlink crashing script
            McShaman Level 1

            Thanks Ping, but I am actually trying to check each destination against every hyperlink/source to see if they are linked... But when it trys to check a broken external link it errors out.

             

            If I can identify what hyperlinks are broken external page hyperlinks before doing the check I can skip over them... But I cant.

             

            I could use a try{} statement with an empty catch{} but there has to be a more elegant way of testing for this.