Skip to main content
Participating Frequently
February 3, 2014
Question

Automated link creation?

  • February 3, 2014
  • 2 replies
  • 1030 views

We produce a monthly catalogue that contains approximately 500 part numbers that appear in the form of 'XXXX XXXX'.

Once the catalogue has been sent to print we use a third party online eBook creator that auto detects all instances of 'XXXX XXXX' and then inserts static text (http://abc.com.au/search?q=) before the part number to create a hyperlinked URL, eg.

http://abc.com.au/search?q=05512365

My question is, is InDesign capable of doing the same thing?

Apologies if I haven't explained myself very well - am more than happy to provide more info if it helps.

Thanks in advance.

This topic has been closed for replies.

2 replies

josh009Author
Participating Frequently
February 24, 2014

OK, i'm back again.

Seems I need to revise the original request.

Now we need to detect the part number (XXXX XXXX) and inject it into a hyperlink that looks like this:

http://www.abc.com.au/part/00338400?utm_source=BW%20Catalogue&utm_medium=Catalogue&utm_term=00338400&utm_campaign=Catalogue

I've tried playing with the script however keep getting errors

Any help will be most appreciated!

Trevor:
Legend
February 3, 2014

Hi Josh

This is an easy way to do it

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "\\<(\\d\\d\\d\\d) (\\d\\d\\d\\d)\\>";

app.changeGrepPreferences.changeTo = "http://abc.com.au/search?q=$1$2"

var doc = app.activeDocument,

      hyperStyle = doc.characterStyles.itemByName ("Hyperlink Character Style"); // change name or leave as is or remove this line and the line below

if (hyperStyle.isValid) app.changeGrepPreferences.appliedCharacterStyle = hyperStyle; // this is the line below

doc.changeGrep();

app.menuActions.item("$ID/Convert URLs to Hyperlinks...").invoke();

HTH

Trevor

josh009Author
Participating Frequently
February 3, 2014

Hi Trevor,

thanks for the help!

It's almost what I'm after but it's not quite right.

When I run the script it's correctly identifying the part numbers and creating the hyperlinks except rather than continuing to display the part number as XXXX XXXX, it's displaying the full URL, eg. abc.com.au/search?q=XXXXXXXX

Can the script be amended so that the part number displayed in the document remains unchanged?

Thanks again :)

Trevor:
Legend
February 3, 2014

Yep, I misunderstood you there, I should have realized that's what you wanted..

I'm too busy now to do that one but it's quite simple and you should get an answer here soonish, if not I'll try answer if I have time.