How to use data merge with hyperlinks?
There are plenty of post out there about this but in all of my searches I have yet to find a solution which works.
This is my current script:
<<Start Script>>
app.findGrepPreferences = app.changeGrepPreferences = null;
doc = app.activeDocument;
app.findGrepPreferences.findWhat = "(?<=11).*?(?=11)";
var lnks = doc.findGrep();
app.findGrepPreferences.findWhat = "(?<=00).*?(?=00)";
var txts = doc.findGrep();
for (var i = 0; i < lnks.length; i++) {
var urld = doc.hyperlinkURLDestinations.add(lnks.contents);
doc.hyperlinks.add(doc.hyperlinkTextSources.add(txts), urld);
}
alert('Processed '+txts.length+' hyperlinks');
<<End Script>>
I receive an error "the object is already being used by another hyperlink."
Thank you.