Skip to main content
Inspiring
May 15, 2013
Answered

hyperlinkTextSources from hyperlinkTextDestinations text

  • May 15, 2013
  • 1 reply
  • 2371 views

Hi Scripters, big question!!!

With two documents open, I have some hyperlinkTextDestinations previously created by text selections.

Now want to create hyperlinks with hyperlinkTextSources refering to the same text used for anchors.

Trying for hours several solutions and roaming the web with no success, here's a test script:

var myLink = app.documents[0].hyperlinkTextDestinations[0].destinationText.select();

var mySource = app.documents[0].hyperlinkTextSources.add(myLink);

var myAnchor = app.documents[1].hyperlinkTextDestinations[0];

app.documents[0].hyperlinks.add(mySource, myAnchor);

The prob is that i get (line 1) an insertionPoint instead a text selection.

Any indications appreciated,

regards

This topic has been closed for replies.
Correct answer Trevor:

See here for your answer

http://forums.adobe.com/message/4890123#4890123

1 reply

Participant
May 16, 2013

-- by using apple script -> u converted this into java script

eg :  set mydoc to active document -> apple script

    var myDoc = app.activeDocument -> java script

select text of selection

                set SourceText to item 1 of selection as string

                set hrperlnk to hyperlinks

                set LnkTxt to 0

                set HyperLnkTxt to hyperlink text sources

                repeat with i from 1 to count of HyperLnkTxt

                    set HyperLnkSrc to item i of HyperLnkTxt

                    set src to contents of source text of HyperLnkSrc

                    if src is equal to SourceText then

                        set LnkTxt to 1

                        set HyperLnkSrc to item i of HyperLnkTxt

                        exit repeat

                    end if

                end repeat

foreditAuthor
Inspiring
May 16, 2013

Thank you SuriyaRevathi,

but, if I've right understood your script, a selected text is my target (js line 1) not my starting point (it will be at js line 2)

Trevor:
Trevor:Correct answer
Legend
May 19, 2013