![]() |
|
#4
|
||||
|
||||
|
The code I posted runs the searches separately. To do what you suggest requires two macros similar to
Code:
Sub Macro1()
Dim sFindText As String
Dim sReplaceText As String
Dim oRng As Range
sFindText = "%"
sReplaceText = " PERCENT"
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(findText:=sFindText, _
MatchWholeWord:=True, _
Forward:=True, _
Wrap:=wdFindStop) = True
oRng.Text = sReplaceText
oRng.Collapse wdCollapseEnd
Loop
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
Sub Macro2()
Dim sFindText As String
Dim sReplaceText As String
Dim oRng As Range
sFindText = "\"
sReplaceText = " "
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(findText:=sFindText, _
MatchWholeWord:=True, _
Forward:=True, _
Wrap:=wdFindStop) = True
oRng.Text = sReplaceText
oRng.Collapse wdCollapseEnd
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 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find/Replace text longer than 255 characters
|
alex100 | Word VBA | 5 | 07-08-2020 04:14 AM |
Combining Characters in Find & Replace
|
Surge | Word | 6 | 03-10-2020 12:42 AM |
multiple find and replace in vba for special words
|
kvnrao | Word VBA | 7 | 11-02-2018 06:28 PM |
Search and Replace special characters between word using wildcards
|
mauuuuu5 | Word | 1 | 08-23-2015 09:20 PM |
Find and Replace some characters with Bullets
|
kjxavier | Word | 1 | 01-02-2015 12:15 AM |