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

105

Likes

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

Adobe Community Professional , Mar 03, 2022 Mar 03, 2022
Hi @Ronald63, set the "target" argument in your function to "app". - Mark

Likes

Translate

Translate
Adobe Community Professional ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

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

- Mark

Likes

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

Likes

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
Adobe Community Professional ,
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

Likes

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