Skip to main content
Inspiring
November 11, 2014
Answered

How to add para styles in mychange

  • November 11, 2014
  • 2 replies
  • 519 views

Hi All,

In the below coding is lots of find and change. Now I need to mychange one more additional change with S2, i.e. applied one of the paragraph style. Please advice and see below my coding.

var myfind = ["(<display>)(.+)(</display>)", "(<verse>)(.+)(</verse>)"]

var mychange = ["$2", "$2"]

for (k=0; k<myfind.length; k++)

{

    app.findGrepPreferences = app.changeGrepPreferences = null;

    app.findChangeGrepOptions.includeMasterPages = false;

    app.findGrepPreferences.findWhat = myfind;

    app.changeGrepPreferences.changeTo = mychange;

    app.activeDocument.changeGrep();

}

Regards,

Vetha

This topic has been closed for replies.
Correct answer Sajeev Sridharan

Hope I misunderstood your question, try this

myFindChange('(<display>)(.+)(</display>)', '$2', 'display'); 

myFindChange('(<verse>)(.+)(</verse>)', '$2', 'verse'); 

 

 

function myFindChange (findWhat, changeTo, paraStyle){ 

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

     if(findWhat)app.findGrepPreferences.findWhat = findWhat; 

     if(changeTo)app.changeGrepPreferences.changeTo = changeTo; 

     if(paraStyle)app.changeGrepPreferences.appliedParagraphStyle = paraStyle; 

    app.activeDocument.changeGrep(); 

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

Vandy

2 replies

Legend
November 11, 2014

Try this,

myFindChange('(<display>)(.+)(</display>)', '$2');

myFindChange('(<verse>)(.+)(</verse>)', '$2');

function myFindChange (findWhat, changeTo){

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

     if(findWhat)app.findGrepPreferences.findWhat = findWhat;

     if(changeTo)app.changeGrepPreferences.changeTo = changeTo;

    app.activeDocument.changeGrep();

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

}

Vandy

Sajeev SridharanCorrect answer
Legend
November 11, 2014

Hope I misunderstood your question, try this

myFindChange('(<display>)(.+)(</display>)', '$2', 'display'); 

myFindChange('(<verse>)(.+)(</verse>)', '$2', 'verse'); 

 

 

function myFindChange (findWhat, changeTo, paraStyle){ 

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

     if(findWhat)app.findGrepPreferences.findWhat = findWhat; 

     if(changeTo)app.changeGrepPreferences.changeTo = changeTo; 

     if(paraStyle)app.changeGrepPreferences.appliedParagraphStyle = paraStyle; 

    app.activeDocument.changeGrep(); 

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

Vandy

Inspiring
November 11, 2014

Excellent vandy, Thanks a lot

Peter Spier
Community Expert
Community Expert
November 11, 2014

Moved to the scripting forum (InDesign Scripting ). You should ask this type of question here in the future to get the best response.

Inspiring
November 11, 2014

Ya Sure