Skip to main content
demonjamez
Participant
October 16, 2020
Answered

Script to change HyperlinkPageDestination ViewSetting

  • October 16, 2020
  • 1 reply
  • 448 views

Hi.

I am trying to speed up my process of creating page links. As InDesign does not allow the default of 'Fixed' to be changed, I would like to create a script to run through the document and change the setting of all HyperlinkPageDestination ViewSetting.

 

The code I am trying to change is underlined below:

</Properties>
</HyperlinkPageDestination>
<HyperlinkPageDestination Self="HyperlinkPageDestination/.122286" Name=".122286" NameManually="true" DestinationPage="n" ViewSetting="FitWidth" ViewPercentage="105" Hidden="true" DestinationUniqueKey="106">
 
The script I have tried to chop together (amongst others) is:
var doc = app.activeDocument;
for(var i = 0; i < doc.HyperlinkPageDestination.length; i++) {
try {
doc.HyperlinkPageDestination.item(i).ViewSetting = doc.HyperlinkPageDestination.item(i).ViewSetting.replace("Fixed", "FitWindow");
} catch(e){}
};
 
This generates an 'Error Number: 55'. Does not support the property or method 'HyperlinkPageDestination'. The source is:
for(var i = 0; i < doc.HyperlinkPageDestination.length; i++) {
 
If anyone can help, I would really appreciate it.
Thanks in advance.
This topic has been closed for replies.
Correct answer Manan Joshi

Try the following

 

var doc = app.activeDocument;
for(var i = 0; i < doc.hyperlinkPageDestinations.length; i++) {
try {
	doc.hyperlinkPageDestinations[i].viewSetting = HyperlinkDestinationPageSetting.FIT_WINDOW
} catch(e){}
};

 

-Manan

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
October 16, 2020

Try the following

 

var doc = app.activeDocument;
for(var i = 0; i < doc.hyperlinkPageDestinations.length; i++) {
try {
	doc.hyperlinkPageDestinations[i].viewSetting = HyperlinkDestinationPageSetting.FIT_WINDOW
} catch(e){}
};

 

-Manan

-Manan
demonjamez
Participant
October 16, 2020

Many thanks for the reply.

The script runs without error, but does not change the ViewSetting.

Community Expert
October 16, 2020

Try it again, I edited the code after I posted the first time. The viewSettings had a typo, the v should be lowercase. No errors are shown because of the try-catch block

-Manan

-Manan