In scripting, find and replace works on a text object or collection. So
you would need to get a reference to all the text on your page, and run
the findText() method on that.
For instance, in the easy case that there is only one text frame on your
page, and assuming that the variable myFrame holds that text frame, you
would simply do:
myFinds = myFrame.findText();
(this is assuming you've set all the findTextPreferences as necessary to
find what you're looking for).
Thanks for the quick response.
Unfortunately... it is not the easy case of only one text frame.
What leads to another question.
Is there a easy method to make a collection of all text frames on a page?
Well, if you have a look at the InDesign DOM (under the Help menu in
ESTK), you'll see that a page has a property called textFrames, which is
a collection of text frames on that page.
So to search all the text frames on a given page, you should be able to do:
myFinds = myPage.textFrames.everyItem().findText();
The InDesign DOM is so logical and stil I do not always follow it...
I was able to do what you suggest.
And your suggestion worked well. The performance of my script got a boost.