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

get master page by name with out prefix

Explorer ,
Dec 17, 2019 Dec 17, 2019

 

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

 

Capture.PNG

TOPICS
Scripting
828
Translate
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];

    }

}

Translate
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];

    }

}

Translate
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

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 )

Translate
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
LATEST

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

 

 

Translate
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