Article View: adobe.scripting.indesign
Article #8149(JS) Adding hyperlinks
From: krasno_larry
Date: Tue, 07 Nov 2006 21:42
Date: Tue, 07 Nov 2006 21:42
29 lines
2029 bytes
2029 bytes
Using Mac osx 10.4.8 & Indesign CS2
I have an indesign document which contains about 450 pages. Each page has a title, an author list & an abstract. The title uses the paragraph style "title", the author list uses the paragraph style "author" & the abstract uses the paragraph style "abstract".
I want my script to sequence throught the document and at each instance of the "Title" paragraph style, I want to create a hyperlink destination.I plan to write other scripts so other Indesign documents can refer to the destinations I will create with this script(I have done similiar linking manually in the past).
The js code I am using is as follows:
var myDoc = app.activeDocument;
var num_pars = myDoc.stories[0].paragraphs.length;
for (i =0; i<num_pars; i++) { if( myDoc.stories[0].paragraphs.item(i).appliedParagraphStyle.name == "Title" ) {
var text_source =myDoc.stories[0].paragraphs.item(i).contents;
text_source = "abc.com";
myDoc.hyperlinkTextDestinations.add(text_source);
}
}
Note: I redefined the variable text_source for test purposes.
When I step through the script with Extend Script Toolkit, and I get to the ".add", I get an error message that says:
"Invalid value for parameter 'destination' of event 'add'. Expected Text, but received "abc.com".
What, if anything, am I doing wrong?
Thanks in advance for any assistance.
Larry
Technical Details
Message-ID:
<3bc235ac.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.albasani.net!news.isoc.lu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f939a,20057d8f7e7220f3 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: krasno_larry@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.albasani.net!news.isoc.lu!webcrossing Newsgroups: adobe.scripting.indesign Subject: (JS) Adding hyperlinks Message-ID: <3bc235ac.-1@webcrossing.la2eafNXanI> Date: Tue, 7 Nov 2006 13:42:13 -0800 Lines: 40 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit