Skip to main content
BEGINNER_X
Legend
March 25, 2013
Question

Preserve Manual Overrides

  • March 25, 2013
  • 2 replies
  • 1199 views

Hi All,

I have a script which find  all the paragraph styles in myFind Array and change all the paragraph styles as per in the name of myChange Array.

Request:

Changing Paragraphs Styles without clear overrides or preserve local overrides like manual bold, italic etc....

script:

var myFind = ["H1", "H2", "H5"]

var myChange = ["a_H1", "a_H2", "a_H5"]

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

     app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

     app.findGrepPreferences.appliedParagraphStyle = myFind;

     app.changeGrepPreferences.appliedParagraphStyle =myChange;

     app.activeDocument.changeGrep();

     app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

     }

Could anyone give solution for preserve clear overrides.

Thanks in advance

Beginner

This topic has been closed for replies.

2 replies

Jump_Over
Legend
March 25, 2013

Hi,

mFound = app.activeDocument.changeGrep();

You need to go back into mFound array and use .clearOverrides() method with each element

Jarek

Trevor:
Legend
March 25, 2013

Hi Jarek,

I think x wants to  preserve the local format and not clear the local overrides.

The English there is not too clear to say the least.

Either way the changeGrep() would clear the local formating without using clearOverrides(), which I think was the source of his problem

Regards

Trevor

BEGINNER_X
Legend
March 25, 2013

Dear Trevor/Jump_Over,

I want to preserve locat format (i.e., maintain manual bold, italic etc...)

Trying Trevor script. But please find the screenshot

var myFind = ["H1", "H2"]

var myChange = ["a_H1", "a_H2"]

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

     app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

     app.findGrepPreferences.appliedParagraphStyle = myFind;

      myFind.applyParagraphStyle(app.activeDocument.paragraphStyles.itemByName(myChange),false)

//~      //app.changeGrepPreferences.appliedParagraphStyle =myChange;

//~      //app.activeDocument.changeGrep();

     app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

     }

Trevor:
Legend
March 25, 2013

As far as I know you can't use changeGrep to do it but you can use find grep and then loop through the finds and do

myFinds.applyParagraphStyle (app.activeDocument.paragraphStyles.itemByName(myChange),false)