Reply To: Applying a master based on paragraph style

Home Page / Forums / General InDesign Topics (CLOSED) / Applying a master based on paragraph style / Reply To: Applying a master based on paragraph style

#99448

I know this is late but it’ll be a good reference for future visitors.

I believe your question has been answered here: https://forums.adobe.com/thread/1027292

Just in case the website doesn’t exist in the future, here’s the code:

var myDocument = app.activeDocument;
var myParas = myDocument.stories.everyItem().paragraphs.everyItem().getElements();
var myPage = myDocument.pages;
for(i=0; i<myParas.length; i++)
{
    if(myParas[i].appliedParagraphStyle.name == "CT")  
    {
        //Works only in CS5 and later
        myParas[i].parentTextFrames[0].parentPage.appliedMaster = myDocument.masterSpreads.item("B-Master");
        //for CS4 use this
        //myParas[i].parentTextFrames[0].parent.appliedMaster = myDocument.masterSpreads.item("B-Master");
    }
}

This article was last modified on November 7, 2017

Comments (0)

Loading comments...