RIAS
asked on
Find and replace in mail merge
Hello,
I have a code which works perfectly to find and replace but, how can I avoid repetition.
I have a code which works perfectly to find and replace but, how can I avoid repetition.
Dim FindObject As Word.Find = oDoc.Content.Find
With FindObject
.ClearFormatting()
.Text = "«" & "Dr" & "*»"
.Replacement.ClearFormatting()
.Replacement.Text = ""
.Forward = True
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False '
.Execute(Replace:=Word.WdReplace.wdReplaceAll)
End With
With FindObject
.ClearFormatting()
.Text = "«" & "Mo" & "*»"
.Replacement.ClearFormatting()
.Replacement.Text = ""
.Forward = True
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False '
.Execute(Replace:=Word.WdReplace.wdReplaceAll)
End With
With FindObject
.ClearFormatting()
.Text = "«" & "Ve" & "*»"
.Replacement.ClearFormatting()
.Replacement.Text = ""
.Forward = True
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False '
.Execute(Replace:=Word.WdReplace.wdReplaceAll)
End With
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! Worked like charm!
ASKER