Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 10-23-2016, 09:00 PM
gmayor's Avatar
gmayor gmayor is offline Need some vba code to search a word document an replace it if len = 3 Windows 10 Need some vba code to search a word document an replace it if len = 3 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Search for br.[!0-9] with the wildcard option set. http://www.gmayor.com/replace_using_wildcards.htm

Code:
Sub Replace_br()
Dim orng As Range
    Set orng = ActiveDocument.Range
    With orng.Find
        Do While .Execute(FindText:="br.([!0-9])", ReplaceWith:="bread\1", MatchWildcards:=True)
            orng.Collapse 0
        Loop
    End With
lbl_Exit:
    Set orng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com

Last edited by gmayor; 10-23-2016 at 11:32 PM.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some vba code to search a word document an replace it if len = 3 VBA code to compile one document based on multiple search terms Hoxton118 Word VBA 4 04-04-2021 06:02 AM
Search Replace Code BolligeA1 Word 8 02-22-2016 12:32 PM
Search and Replace vba Word 2003 tariqaleed2 Word VBA 9 08-19-2014 03:34 AM
Search and replace/insert HTML code into Master File using tags dave8555 Excel 2 02-23-2014 03:51 PM
Need some vba code to search a word document an replace it if len = 3 WORD: Rtf and search-replace (regexp/fonts) seteshpl Word 1 09-06-2011 01:35 AM

Other Forums: Access Forums

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