Skip to main content
TᴀW
Legend
December 20, 2010
Question

Add a hyperlink to another document? CS4

  • December 20, 2010
  • 1 reply
  • 1944 views

Hi,

How would one add a hyperlink to a document that refers to another document?

The basic is:

myDoc.hyperlinks.add(myHyperlinkTextSource, myHyperlinkTextDestination);

How do I get "myHyperlinkTextDestination" if it exists in another, unopened InDesign document?

I suppose I could open the document, get the Hyperlink destination, and then close it again, but in the UI this is not necessary (you simply browse to the required file and can then choose from a list of hyperlink destinations in that file). So how is this scripted?

Thanks,

Ariel

This topic has been closed for replies.

1 reply

TᴀW
TᴀWAuthor
Legend
December 20, 2010

Next, I tried this:

I opened the document and got it's HyperlinkTextDestination.

Then I used it when adding the hyperlink to the main document:

app.activeDocument.hyperlinks.add(mySource, myDestination) //myDestination is a hyperlink destination in another document.

And I get the following error message:

Cannot set this property to an object in another document.

So I'm clearly on a wild goose chase here.

But obviously this is possible since it is doable in the UI.

Any and all help appreciated!

Ariel

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
Jongware
Community Expert
Community Expert
December 20, 2010

Hi Arïel,

Have you looked at HyperlinkExternalPageDestination?

"A hyperlink destination that is a page in a document other than the document that contains the hyperlink source."

(I have no idea how to use it, but one of its properties is "documentPath" -- the 'other' document. Sounds good, dunnit?)

TᴀW
TᴀWAuthor
Legend
December 20, 2010

Hi Jongware,

I did notice that, but:

a. I have no idea how to use it either; and more importantly:

b. I have to use textDestinations and not page destinations.

Look, I'll explain why I need this stuff, and maybe you can tell me that

I've got it all wrong:

I'm creating an eBook of the Book of Psalms. The publisher wants a table

of contents as a page (apart from the one that Adobe Digital Editions

adds as a toolbar on the left).

So I've got an InDesign book with 150 documents (one per psalm so it

starts on a new page. InDesign CS4 here).

So I've added a document with a list of the chapters. I was able to

script a hyperlinkTextDestination at the beginning of each chapter

(which saved me doing that 150 times).

Now I want to script a textSource for each line in the TOC that will

link up with the text destination

Ideas suggestions etc. welcome, but especially I would like to know how

to script a text source that points to a text destination in an external

document.

Thanks,

Ariel

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators