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!
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?)
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
Well, having Googled "hyperlink TextDestination external" I finally came across this
Looks like he found a solution very similar to what I posted in the second message in this thread. I'm going to give it a shot.
You can create a hyperlink with a destination in another document, but I believe it must be open. You can open it with no window if you'd like.
The hyperlink must be added to the document with the source.
Thanks. Yup, you're right, the external document must be temporarily
opened. The thread I linked to in my previous post shows exactly how
this should be done, and it finally worked for me.
Phew! That saved 150 tedious repetitions (well, actually 90. I had
already started doing the first 60 manually!)