How to find and replace multiple words at the same time in a Word document?

How to find and replace multiple words simultaneously in a Word document? While Word provides a Find and Replace feature to find all instances of a word or phrase and replace them with a new word at once, it may not be convenient when you want to find and replace various words simultaneously. In this article, we’ll discuss a VBA method to find and replace multiple words at the same time in a Word document.

Find and replace multiple words at once in Word using VBA

Follow these steps to find and replace multiple words simultaneously in a Word document:

  1. Press Alt + F11 to open the Microsoft Visual Basic for Application window.
  2. In Microsoft Visual Basic for Application, click on Insert > Module. Then copy the VBA code below and paste it into the Module window.
Sub FindAndReplaceMultiItems()
‘ Update by ExtendOffice 2018/10/25
Dim xFind As String
Dim xReplace As String
Dim xFindArr, xReplaceArr
Dim I As Long
Application.ScreenUpdating = False
xFind = InputBox(“Enter items to be found here, separated by comma: “, “Kutools for Word”)
xReplace = InputBox(“Enter new items here, separated by comma: “, “Kutools for Word”)
xFindArr = Split(xFind, “,”)
xReplaceArr = Split(xReplace, “,”)
If UBound(xFindArr) <> UBound(xReplaceArr) Then
MsgBox “Find and replace characters must be equal.”, vbInformation, “Kutools for Word”
Exit Sub
End If
For I = 0 To UBound(xFindArr)
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = xFindArr(I)
.Replacement.Text = xReplaceArr(I)
.Format = False
.MatchWholeWord = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next
Application.ScreenUpdating = True
End Sub
  1. Press F5 to run the code.
  2. In the first Kutools for Word dialog, enter the words you want to find and replace in the text box, separating them with commas, then click OK.
  3. In the second Kutools for Word dialog, enter the new words to replace the old ones (also separated by commas), then click OK.

    How to find and replace multiple words at the same time in a Word document

    How to find and replace multiple words at the same time in a Word document

Note: In this example, all instances of “KTE” in the document will be replaced with “Complete”. Adjust them according to your needs. “Finish” and “Test” will be replaced with “KTW” and “KTO”, and “New” will be replaced with “New”.

Gotkey.net
Logo
Compare items
  • Total (0)
Compare
0
Shopping cart