An implementation of Visual Basic that is built into Microsoft products.
Hi, SteveD
Yes, it is possible, but not by searching Window 2 with the exact text from Window 1.
Right now your code finds 8 REVISION in Window 1, stores that exact text in strText, then looks for the exact same text in Window 2. That will not match 8 36951 REVISION because Word sees it as different text.
What you need in Window 2 is a wildcard search, for example:
.Text = "8 [0-9]{1,} REVISION"
.MatchWildcards = True
Or, if you want to build it from strText, replace the space with a wildcard numeric block.
Also, it is recommended that you use a Range instead of Selection where possible. Selection depends on the active window and can jump around, while Range.Find is usually more stable for this kind of cross-window search.
So the main fix is: don’t search Window 2 for the literal strText, search for a wildcard pattern that allows digits between 8 and REVISION.
This matches the documented behavior of Word VBA Find, where Selection.Find changes the active selection, while Range.Find redefines the range without changing selection, and Word wildcard search supports patterns like {n,} for repeated digits.
Thank you for your patience in reading, I hope this information has been helpful to you.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment."
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.