• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Target the Source Hyperlink Destination Document of an Hyperlinks

Community Expert ,
Sep 16, 2020 Sep 16, 2020

Copy link to clipboard

Copied

I have a bunch of InDesign Doc, with Hyperlink with source are an anchor text in others InDesign document. If I rename the source document, all the hyperlink will be broken.

I have a script that can perform a GREP change/replace but it for URL Destination.

 

How can I edit this part to change it to the Document Destination name instead.

 

This part need to be edited.

var dests = app.documents[0].hyperlinkURLDestinations.everyItem().getElements();
	for(var i=0;i<dests.length;i++){
		dests[i].destinationURL = dests[i].destinationURL.replace(grepForFind,grepForReplace);

 

TOPICS
Scripting

Views

734

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 11, 2020 Oct 11, 2020

Hi Jean-Claude. This is a murky area of hyperlinks, and unfortunately what you're after -- change the name of the document that contains the targeted text anchor -- isn't possible. When the destination is an external page, you can simply set the target document's path using the documentPath property. But for external text anchors that property is not available.

 

Given a document with one hyperlink whose destination is a text anchor in another document,

app.documents[0].hyperlinks[0].destination
...

Votes

Translate

Translate
Advocate ,
Oct 10, 2020 Oct 10, 2020

Copy link to clipboard

Copied

If you share some of those destination URL, or share some more information.

Then it is easy to help you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 10, 2020 Oct 10, 2020

Copy link to clipboard

Copied

Hi,
The issue here is with hyperlinks which targer are an anchor text inside differents document. If you change the name of theses InDesign document, the hyperlinks are all broken. But internally, they are still there but not visually accessible to the UI. So It would be usefull to rename the destination indesign document internally with a script.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2020 Oct 11, 2020

Copy link to clipboard

Copied

Hi Jean-Claude. This is a murky area of hyperlinks, and unfortunately what you're after -- change the name of the document that contains the targeted text anchor -- isn't possible. When the destination is an external page, you can simply set the target document's path using the documentPath property. But for external text anchors that property is not available.

 

Given a document with one hyperlink whose destination is a text anchor in another document,

app.documents[0].hyperlinks[0].destination

returns the external text anchor, and 

app.documents[0].hyperlinks[0].destination.parent

 returns the external document. There's no way you can change that.

 

The script's behaviour, when you call 'app.documents[0].hyperlinks[0].destination', is an error:

Error: Hyperlink destination document not found. Please verify the document's location in the Hyperlinks panel before choosing this hyperlink.

 

which of course is pretty dumb, but there you are.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2020 Oct 11, 2020

Copy link to clipboard

Copied

LATEST

Thanks for replying...
Too bad we can’t access this information (that are still in the document) when the document is missing or rename.

Only workaround found so far is to do find/replace on .idml

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines