• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Find/change grep by script for all open INDD documents

Enthusiast ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

Hi everyone

I want to find/change grep by script for all open INDD documents.

What value for target variable ?

/* grep search */
function INDD_search(target,search,findparastyle, findcharstyle) {
/* init pref */
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
/* find params */
app.findGrepPreferences.findWhat = search;
app.findGrepPreferences.appliedParagraphStyle = findparastyle;
app.findGrepPreferences.appliedCharacterStyle = findcharstyle;
/* run grep */
var result = target.findGrep();
/* init pref */
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
return result
}

Thanks for your help

Regards
Ronald

TOPICS
Scripting

Views

249

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 03, 2022 Mar 03, 2022

Hi @Ronald63, set the "target" argument in your function to "app".

- Mark

Votes

Translate

Translate
Community Expert ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

Hi @Ronald63, set the "target" argument in your function to "app".

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

It's OK, thank you Mark
Sometimes I find myself really stupid... šŸ˜‰
Ronald

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2022 Mar 04, 2022

Copy link to clipboard

Copied

LATEST

Nah, not stupidā€”it's only obvious after the answer is shown.

 

If it helps for next time a problem arises like this, here's my thinking process for this question: the findGrep() function is a method of what objects? various text objects, textFrames, pages, spreads, documents all have it... all no good for your situation unless we iterate over all the open documents. Hmmm, could do that, combining the results after each findGrep. But then I realised there was an object that "contains" all documents: App. I had a look in the documentation and yes! it has a findGrep method. Tested your function and it worked.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines