Flush bad karma from Word's find facility after an unsuccessful wildcard search
Article contributed by Bill Coan
There is a bug in Word that means any Find or Find or Replace operation in
VBA that follows an unsuccessful wildcard
search may sometimes fail. The following code fixes this problem.
myWorkingRange = ActiveDocument.Range
'call a routine that removes any previous settings from the find dialog
'exit sub if search is successful
"tell the user something"
'this is a dummy search because otherwise
'subsequent searches will break down
'somehow this search flushes the bad karma
'and lets subsequent searches function
'call a routine that removes all settings from the find dialog
'so future users of the dialog won't get strange results
.Wrap = wdFindStop
Note: There is no simple way to reproduce this bug. In a macro that
makes dozens of wildcard searches, the bug will eventually manifest itself, but
I don't know of a way to force the bug to appear. The good news is that if you
use the above workaround, the bug will never appear.
How to prevent the built-in BrowseNext and RepeatFind commands from creating bad karma for wildcard searches