Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

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.
  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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RIAS

ASKER

Thanks, trying brb
Avatar of RIAS

ASKER

Thanks! Worked like charm!