Skip to main content
hamdifem
Inspiring
February 3, 2015
Answered

about override all page

  • February 3, 2015
  • 1 reply
  • 376 views

Located in the master page

object style applied to a text frame (myobjstyle1)

if only in the "Test" writes

override it in all pages

How to script

var myDocument = app.activeDocument;   

var TotalPages = (myDocument.pages.count());   

for(var CurrentPage=0; CurrentPage < TotalPages; CurrentPage++) {   

     OverrideMasterItems();   

}   

  function OverrideMasterItems() { 

    var theActiveOS = myDocument.objectStyles.item("myobjstyle1");

    var allItems = myDocument.pages[CurrentPage].appliedMaster.pageItems.everyItem().getElements();   

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

        try{ 

            if (allItems.appliedObjectStyle == theActiveOS) {

                  //if(allItems.contents = "Test"                     //???

                allItems.override(myDocument.pages[CurrentPage]); 

            } 

        }  

        catch(e){}   

    }  

}

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

If you want something ==> check if it is possible (i.e. using Object Models here Indesign JavaScript Help)

You can not check appliedParagraphStyle property for object "PageItem".

You can do it for allItems.texts[0]

Jarek

1 reply

Jump_Over
Legend
February 3, 2015

Hi,

Think is almost done.

modify this:

if(allItems.contents == "Test");


Jarek

hamdifem
hamdifemAuthor
Inspiring
February 3, 2015

thank you very much

it worked in this way

if (allItems.appliedObjectStyle == theActiveOS && allItems.contents == "Test") {

}

I wanted to add paragraphstyle, but did not run

var theActivePS = myDocument.paragraphStyles.item("myParStyle 01");

allItems.appliedParagraphStyle == theActivePS

Jump_Over
Jump_OverCorrect answer
Legend
February 3, 2015

Hi,

If you want something ==> check if it is possible (i.e. using Object Models here Indesign JavaScript Help)

You can not check appliedParagraphStyle property for object "PageItem".

You can do it for allItems.texts[0]

Jarek