Reply To: Scripting hyperlink replacement

#66853

Well, it should work right out of the box (providing you have some hyperlinks in your document).

What sort of database are your Abbreviations/Hyperlinks in? If you can export them to a simple text list, you can have the script look them up automatically. That would be something like (warning: making this up as I type):

// add this list at the very top of the script;
// take note to close all the [ that you open ], nested as shown
var abbrList = [ [“AAA”, “https://creativepro.com”%5D,
[“AAB”, “https://www.adobe.com”%5D,
[“XYZ”, “https://forums.adobe.com/community/indesign?view=discussions”%5D,
[“MIT”, “https://jongware.mit.edu/idcs6js/index.html” ] ]; // etc. — full hyperlinks!

and then instead of inserting a plain fixed text

r.texts[0].contents = “AAA”;

replace it with a loop over the abbrList array, checking if the link is in there and inserting the proper abbreviation if found:

r.parentStory.contents = “???”;
for (j=0; j<abbrList.length; j++)
if (abbrList[j][1] == links[i].destination.destinationURL)
{
r.parentStory.contents = abbrList[j][0];
break;
}

Also, add this line under the comment line:
// set some Anchored Object properties

r.anchoredObjectSettings.anchorPoint = AnchorPoint.BOTTOM_RIGHT_ANCHOR;

— I found the position from the left margin and baseline depends on your current *default* settings, and they happened to be correct for my initial test.

This article was last modified on January 28, 2014

Comments (0)

Loading comments...