View Single Post
 
Old 01-28-2023, 05:18 PM
harry harry is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Jul 2010
Posts: 31
harry is on a distinguished road
Default

Thanks for your further reply. However, the issue appears to be not with the scope of the search but with the execution of the search. The search string is always found in the expected place; the issue is that when a wildcard macro is preceded by another macro, the first match is not found by the wildcard macro until the user presses Shift F4 (Find next), whereas the first match should be found immediately when the macro is run (as it is when the wildcard macro is run by itself).

The cause appears to be something to do with the end-of-document prompts that appear at the end of the preceding macro.

Test 4:
- Go to the beginning of the document.
- Run the "WildcardsFalse" macro.
- When it finds the first match (the "a" in "taxi"), type "Q" to replace it, then press Shift+F4 ("Find next").
- When it finds the next match (the "a" in "above"), press F4 ("Repeat last action") to replace it, then press Shift+F4 to continue searching.
- When it finds the next match (the "a" in "boat"), press F4 to replace it. At this point, don't press Shift+F4, so there are no end-of-document prompts.

- Go to the beginning of the document.
- Press the keyboard shortcut to run the "WildCardsTrue" macro.
- It correctly finds the first match (the "x" in "taxi"). No issue in this case.

Test 5:
- Go to the beginning of the document.
- Run the "WildcardsFalse" macro.
- When it finds the first match (the "a" in "taxi"), type "Q" to replace it, then press Shift+F4 ("Find next").
- When it finds the next match (the "a" in "above"), press F4 ("Repeat last action") to replace it, then press Shift+F4 to continue searching.
- When it finds the next match (the "a" in "boat"), press F4 to replace it, then press Shift+F4 to continue searching.
- Word displays a prompt ("We've reached the end of the document. Do you want to continue searching from the beginning?"); click on Yes.
- Word displays another prompt ("No results found" [OK]"); click on OK.

- Go to the beginning of the document.
- Press the keyboard shortcut to run the "WildCardsTrue" macro.
- Instead of finding the first matching character (the "x" in "taxi"), nothing happens; this is the issue. If you press Shift+F4 (Find next) at this point, then the first match will be found, but it should be found immediately when the macro is run (as it is when the macro is run by itself).

The essential difference between Test 4 (which doesn't have the issue) and Test 5 (which does have the issue) is that Test 4 skips the end-of-document prompts at the end of the preceding macro. (I can't skip these as a work-around, as I need to include the end-of-document prompts as part of a consistent procedure.)
Reply With Quote