VBA Word macro - find and replace from a list
Hi
I am using a very simple code to find and replace a sentence, but there is a location name in the middle, which can be different (up to 300 versions) - is there a way to access a list using one piece of code, rather than copy and paste the code loads of times and change the variant?
I have made the following simpler for ease, but normally there would be more text to find - it's the location that is the issue.
Thanks in advance for any help
Code:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "arriving at Paris at ([0-9])([0-9])."
.Replacement.Text = "will arrive at Paris /1/2."
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "arriving at New York at ([0-9])([0-9])."
.Replacement.Text = "will arrive at New York /1/2."
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "arriving at Paris at ([0-9])([0-9])."
.Replacement.Text = "will arrive at Paris /1/2."
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll