Find text command in inDesign

Has anyone had any success with the find text command in inDesign?

I have documents with large tables with hundreds of cells. There is some text that we need to locate in cells and decide if we need to replace or delete it.

Currently we’re doing that through the user interface and it’s time consuming and error prone.

Ideally I’d like to do a search for a term, get a list of everyplace that term occurs in context (a few words before and after would be fine).

But just getting the first step, successfully scripting the find text command is what I need now.

It’s pretty simple:

tell application id "com.adobe.InDesign" 
	set find text preferences to nothing -- clear them out
	set find what of find text preferences to "first"
	set allFinds to find text parent story of text frame 1 of document 1
end tell

If you want to change text in every table of the doc:

 tell application id "InDn"
	
	set theScope to object reference of (tables of stories of active document)
	
	--RàZ des prefs
	set find text preferences to nothing
	set change text preferences to nothing
	set find change text options to nothing
	
	--prépare
	set find what of find text preferences to "textFind"
	set change to of change text preferences to "textChange"
	
	--remplace
	change text theScope
	
end tel

These are both very helpful. Thanks much.

I’ve already got Myriad Tables display showing the finds, and the context, which tells the user (me, for now) if they need to do the UI find.

Next step will be to do the changes directly from the MT table display.