Skip to main content
Known Participant
August 19, 2019
Answered

Override master page text frame with specific paragraph style

  • August 19, 2019
  • 2 replies
  • 1006 views

Hi everyone!

I have this code that override all text frames from master pages in a document

var doc = app.activeDocument;

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

            var page = doc.pages;

            if (page.appliedMaster !== null) {

                for (j = 0; j < page.appliedMaster.textFrames.length; j++) {

                    try {

                        page.appliedMaster.textFrames.override(page);

                    } catch(e) {}

                }

            }

        }

But I want to override only the text frames with specifics paragraph styles applied. How can I achieve this?

Thank you in advance!

This topic has been closed for replies.
Correct answer platm72

Hi,

try this:

var doc = app.activeDocument;  

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

            var page = doc.pages;  

            if (page.appliedMaster !== null) {  

                for (j = 0; j < page.appliedMaster.textFrames.length; j++) { 

                    try {  

                        switch ( page.appliedMaster.textFrames.parentStory.appliedParagraphStyle.name ) {

                            case 'your 1 paragaraph style name' :

                            case 'your 2 paragaraph style name' :

                                page.appliedMaster.textFrames.override(page);  

                            break;

                               }

                    } catch(e) {}  

                }  

            } 

        }

regards

a.

2 replies

Community Expert
February 24, 2020

FWIW: All code in both posts was damaged when this discussion was transferred from the old Jive-based forum to the new forum software. Hope, that the authors come back and fix the code.

 

Regards,
Uwe Laubender

( ACP )

platm72
platm72Correct answer
Inspiring
August 19, 2019

Hi,

try this:

var doc = app.activeDocument;  

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

            var page = doc.pages;  

            if (page.appliedMaster !== null) {  

                for (j = 0; j < page.appliedMaster.textFrames.length; j++) { 

                    try {  

                        switch ( page.appliedMaster.textFrames.parentStory.appliedParagraphStyle.name ) {

                            case 'your 1 paragaraph style name' :

                            case 'your 2 paragaraph style name' :

                                page.appliedMaster.textFrames.override(page);  

                            break;

                               }

                    } catch(e) {}  

                }  

            } 

        }

regards

a.

RibnogAuthor
Known Participant
August 19, 2019

Works! Thank you so much!

"switch/case" was a nice solution!

leilagolden
Known Participant
February 23, 2020

Greetings Ribnog & Platm72

I'm maybe an advanced novice in indesign, working on a Windows 10 computer with CS6. I am laying out a book in which I'm using hanging indents, and I'd like both the first line of the hanging indents and the subheads to go beyonnd the text frame by 3/8 of an inch. 

I see on ths thread that there's a code for this, which is exciting - only I don't know how or where to enter the code!

Where, in paragrph styles would I enter it? and would I just "outdent" the particular lines?

Grateful for any help!