Hmmm, not sure how |I can describe it better.
A Range.Find (even if you make the entire document the range) when executed CHANGES the range with each Found.
So, say you have:
Blah blah blah cat blah blah
blah yadda cat yadda cat.
You make the range the whole thing. Now you do a Find for "cat".
The first Found makes the range = the first cat. You can test this by getting the Start and End of the .Found.
Continuing on, the Find operation starts at the END of current .Found. Thus the first "cat" is BEHIND the current search forward point. Thus the next .Found will be the second "cat".
HOWEVER....if you do something with the .Found (i.e. the first "cat"), change something - say a Bold operation - then the Find operation starts at the START of the current .Found.
Thus the first "cat" is IN FRONT of the current search point. Thus the next .Found will be the SAME "cat". It will loop.
So, if you CHANGE the .Found, you need to use .Collapse to move the search forward point to the end of the .Found range.
The most important point is that a .Find operation on a range changes the actual range Start and End numbers.
|