Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-24-2024, 08:26 PM
Guessed's Avatar
Guessed Guessed is online now Method A or Method B Windows 10 Method A or Method B 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


I think that looping through all fields is inefficient and would prefer a more direct Find method. This doesn't move the selection if there are no more Ref fields so you could add a complication for that wrinkle (and potentially allow the find to wrap).
Code:
Sub FindMeSeymour()
  ActiveWindow.View.ShowFieldCodes = True
  With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "^d REF"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .MatchCase = False
    .Execute
  End With
  ActiveWindow.View.ShowFieldCodes = False
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method A or Method B Changing Recorded Macro Selection/Clipboard Method to Range/FormattedText Method zanodor Word VBA 5 07-15-2022 01:25 AM
VBA Excel method Not working grandneos Excel 2 01-07-2022 11:19 AM
OrganizerCopy method for ActiveDocument AnnaNmty Word VBA 4 07-25-2018 08:31 PM
Method A or Method B Sorting method Steve Bartko Excel 6 10-26-2016 11:38 AM
Method A or Method B Why no 'SaveCopyAs' method? Cosmo Word VBA 4 10-18-2013 05:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:27 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