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
Hi @Ronald63, set the "target" argument in your function to "app".
- Mark
Copy link to clipboard
Copied
Hi @Ronald63, set the "target" argument in your function to "app".
- Mark
Copy link to clipboard
Copied
It's OK, thank you Mark
Sometimes I find myself really stupid... š
Ronald
Copy link to clipboard
Copied
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