Hi,
the search is looking for an end item, so if you have a Locals.myVar, and it is not used anywhere, then it will not be found by "Locals.myVar". Searching for "myVar" however will find it.
So the principle will be to gather all the variable's you're concerned with (locals and fileglobals at the minimum) and then with that list, search iteratively for the "Locals.xxxxx" and if it finds it somewhere used in an expression, then that will say it's in use. If it doesn't find it, then it's not used as part of the sequence file (not excluding the fact that it may be being used by a code module through the sequence context handle).
You can check for your search terms by being in the sequence editor with the file to search selected and then hit ctrl-F (or go to edit>>Find/Replace) and see what you can find that way. That's effectively what is being automated here by your ActiveX calls.
Thanks
Sacha
// it takes almost no time to rate an answer