Thanks for taking the time to try it out and reply.
I had found that article and followed the instructions.
I was changing the style name incorrectly ::blushing::
But now I’m getting a java script error 21 that the problem is with the following line
myParas[i].parentTextFrames[0].parentPage.appliedMaster = myDocument.masterSpreads.item(“B-Master”);
I tried
1. changing “B-Master”to my master name. I assumed I was supposed to keep the letter heading. Mine also is B so I wrote it as “B-chapterpage”
2. When that didn’t work, I changed the name of my master back to B-Master and reset that part of the script to the original, changing only the style name.
And I’m getting that error. What am I doing wrong?
This is what my personalized script now looks like:
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 == “chapternumber”)
{
//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”);
}
}