A family of Microsoft word processing software products for creating web, email, and print documents.
Thank you.
Sub ReplaceMultipleWords()
Dim searchWords As Variant
Dim replacementWord As String
Dim i As Long
Dim rng As Range
' Array of search words to be replaced
searchWords = Array("dog", "cat", "bird")
' Word to replace the search words
replacementWord = "pet"
' Loop through each search word in the array
For i = LBound(searchWords) To UBound(searchWords)
Set rng = ActiveDocument.Content
With rng.Find
.ClearFormatting
.Text = searchWords(i)
.Replacement.Text = replacementWord
.MatchWholeWord = True ' Match only whole words
.MatchCase = False ' Ignore case sensitivity
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Next i
End Sub
Best Regards
Fuad