GREP Search “Selection” or “Story” ExtendScript ?
When looking for Searching via “Selection” or “Story” through GREP using a script — it expands into this convoluted rabbit hole, when you would imagine it would be much simpler .
The short and sweet script, below, works but affects the entire document. I attempted placing “selection” in various places, and tried creating variables to point to various iterations of app.pageItem.selection , app.selection , etc . To no avail.
I commented out the last line I attempted.
As always any help is very much appreciated.
Thank you.
//reset GREP preferences
app.findGrepPreferences=app.changeGrepPreferences=null;
//app.findChangeGrepOptions = app.pageItem.selection
app.findGrepPreferences.findWhat="\r";
app.changeGrepPreferences.changeTo=",\s";
app.activeDocument.changeGrep();
app.findGrepPreferences=app.changeGrepPreferences=null;
Looking for the javascript syntax that affects Find/Change > GREP > Search > Stories (and/or selection)

