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

get master page by name with out prefix

Explorer ,
Dec 17, 2019 Dec 17, 2019

Copy link to clipboard

Copied

 

Is this possible to access the master page via name without prefix.

 

Capture.PNG

TOPICS
Scripting

Views

681

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 , Dec 18, 2019 Dec 18, 2019

Via scripting, sure. 

 

Edit: Adjusted the object name, thanks to Uwe. 

 

var getMasterByName = function(searchString, doc) {

    for (var i = 0; i < doc.masterSpreads.length; i++) {

         if (doc.masterSpreads[i].name.indexOf(searchString) >= 0) {

            return doc.masterSpreads[i];

    }

}

Votes

Translate

Translate
Community Expert ,
Dec 18, 2019 Dec 18, 2019

Copy link to clipboard

Copied

Via scripting, sure. 

 

Edit: Adjusted the object name, thanks to Uwe. 

 

var getMasterByName = function(searchString, doc) {

    for (var i = 0; i < doc.masterSpreads.length; i++) {

         if (doc.masterSpreads[i].name.indexOf(searchString) >= 0) {

            return doc.masterSpreads[i];

    }

}

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 ,
Dec 18, 2019 Dec 18, 2019

Copy link to clipboard

Copied

FWIW: There is no masterPages collection with Document.

 

But one could build an array:

 

var masterPagesArray =
app.documents[0].masterSpreads.everyItem().pages.everyItem().getElements();

 

Regards,
Uwe Laubender

( ACP )

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 ,
Dec 18, 2019 Dec 18, 2019

Copy link to clipboard

Copied

LATEST

Ack, did it on mobile without checking the DOM! I was just working on a master page script, too... Thanks, Uwe. 

 

 

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