Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Find/change grep by script for all open INDD documents

Enthusiast ,
Mar 03, 2022 Mar 03, 2022

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
491
Translate
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

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

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

- Mark

Translate
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

It's OK, thank you Mark
Sometimes I find myself really stupid... 😉
Ronald

Translate
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
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

Translate
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