Skip to main content
Participant
January 31, 2015
Question

How to use data merge with hyperlinks?

  • January 31, 2015
  • 1 reply
  • 260 views

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.

This topic has been closed for replies.

1 reply

Peter Spier
Community Expert
Community Expert
January 31, 2015

Moved to the InDesign Scripting forum...