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

Script to change HyperlinkPageDestination ViewSetting

New Here ,
Oct 16, 2020 Oct 16, 2020

Copy link to clipboard

Copied

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.
TOPICS
Scripting

Views

319

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 16, 2020 Oct 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

Votes

Translate

Translate
Community Expert ,
Oct 16, 2020 Oct 16, 2020

Copy link to clipboard

Copied

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

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
New Here ,
Oct 16, 2020 Oct 16, 2020

Copy link to clipboard

Copied

Many thanks for the reply.

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

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 16, 2020 Oct 16, 2020

Copy link to clipboard

Copied

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

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
New Here ,
Oct 16, 2020 Oct 16, 2020

Copy link to clipboard

Copied

LATEST

Genius! Works perfectly.

Thank you so much!

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