Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 02-19-2022, 04:33 PM
Guessed's Avatar
Guessed Guessed is offline Help, please, with macro bug Windows 10 Help, please, with macro bug Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

When you record code it relies heavily on the selection object (what is currently selected). The Find dialog behaves differently with a selection vs an insertion point. If there is a selection of some text when you run a find, it only searches inside the selected text. However if the selection is collapsed, the search will either search across the whole document or down to the bottom or up to the top depending on your other settings.

Your code (as recorded) moves the selection object so subsequent searches start from different places and may indeed start with a selected range.

If you keep the above info in your mind, stepping through your code will show you why your later searches fail to find the instances you seek. Paul's code avoids moving the selection object and hence is unaffected by those other factors.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Remove Paras with Line Spac 6; Macro to Convert Paragraphs to Outline Numbered venganewt Word VBA 0 01-25-2022 06:28 PM
Calling macro from loop-all-files macro only opens one file Peterson Word VBA 0 03-27-2021 07:58 PM
Help, please, with macro bug Footnote extraction macro [Why is this macro so slow? / anyway to make it faster?] Le_Blanc Word VBA 10 03-22-2021 11:38 AM
Spell check macro within macro button field doesn't work in one document samuelle Word VBA 0 07-20-2016 02:27 AM
Help, please, with macro bug Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft