Skip to main content
 

How to search and replace across multiple files in Word?

Author: Amanda Li Last Modified: 2024-09-13

If you have several dozen Word files containing the same content, such as headers, footers, or specific words or numbers, and you need to replace this content across all documents, doing it manually can be time-consuming and cumbersome. Fortunately, there are more efficient ways to handle this task. This tutorial will show you tricky methods to replace the same content within multiple Word documents at once, saving you time and effort:

Find and replace texts across multiple Word documents at the same time with VBA code
Easily find and replace different texts across multiple documents at the same time with Kutools for Word


Find and replace texts across multiple Word documents at the same time with VBA code

This method explains how to use a VBA code to search for and replace text across multiple Word documents simultaneously, saving time and effort when dealing with large volumes of files.

  1. Press Alt + F11 to open the Microsoft Visual Basic for Applications window.
  2. In the Microsoft Visual Basic for Applications window, click Insert > Module, then copy and paste the following VBA code into the Module window.
    Sub CommandButton1_Click()
    'Updated by Extendoffice 20180625
    Dim xFileDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
    Dim xFindStr As String
    Dim xReplaceStr As String
    Dim xDoc As Document
    On Error Resume Next
    Set xFileDialog = Application.FileDialog(msoFileDialogFilePicker)
    With xFileDialog
        .Filters.Clear
        .Filters.Add "All WORD File ", "*.docx", 1
        .AllowMultiSelect = True
        i = 1
        If .Show = -1 Then
            For Each stiSelectedItem In .SelectedItems
                GetStr(i) = stiSelectedItem
                i = i + 1
            Next
            i = i - 1
        End If
        Application.ScreenUpdating = False
        xFindStr = InputBox("Find what:", "Kutools for Word", xFindStr)
        xReplaceStr = InputBox("Replace with:", "Kutools for Word", xReplaceStr)
        For j = 1 To i Step 1
            Set xDoc = Documents.Open(FileName:=GetStr(j), Visible:=True)
            Windows(GetStr(j)).Activate
            Selection.Find.ClearFormatting
            Selection.Find.Replacement.ClearFormatting
            With Selection.Find
                .Text = xFindStr  'Find What
                .Replacement.Text = xReplaceStr  'Replace With
                .Forward = True
                .Wrap = wdFindAsk
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchByte = True
                .MatchWildcards = False
                .MatchSoundsLike = False
                .MatchAllWordForms = False
            End With
            Selection.Find.Execute Replace:=wdReplaceAll
            Application.Run macroname:="NEWMACROS"
            ActiveDocument.Save
            ActiveWindow.Close
        Next
        Application.ScreenUpdating = True
    End With
    MsgBox "Operation end, please view", vbInformation
    End Sub
  3. Press F5 to run the code.
  4. In the Browse window, select the documents in which you want to find and replace text, then click OK.

    Browse window

  5. In the first Kutools for Word dialog box, enter the text you want to find in the Find what field and click OK.

    Kutools for Word dialog - Find what box

  6. In the second Kutools for Word dialog box, enter the text you want to replace it with and click OK.

    Kutools for Word dialog - Replace with box

  7. Click OK in the final Microsoft Word dialog box to finish the process.

    Confirmation dialog

In this case, all instances of "Word" in the selected documents are replaced with "Excel" at the same time.


Easily find and replace different texts across multiple documents at the same time with Kutools for Word

Here highly recommend the Batch Find and Replace feature of Kutools for Word. With this feature, you can easily find and replace different texts across multiple Word documents as the same time. Let's see how to apply this feature to find and replace texts across documents.

Kutools for Word, equipped with AI πŸ€–, offers over 100 handy features to simplify your tasks.

1. Please click Kutools Plus > Batch Find and Replace to enable the feature.

Batch Find and Replace button on the ribbon

2. In the Batch Find and Replace dialog box, please configure as follows.

  • 2.1) Click the Add Row button under the Find and Replace tab;
  • 2.2) In the created row fields:
A. Enter the text you will find into the textbox in the Find column
B. Enter the text you will replace with into the textbox in the Replace column;
C. Specify a search type, where to find the text and a color to highlight the text as you need. In this case, I select Full word matching, Main document and a certain color from the Search Type, Find in and Highlight columns;
  • 2.3) Repeat the step 2.1 and 2.2 to add more texts you will find and replace;
  • 2.4) Click the Add button button in the File Type section to add the Word documents in which you will find and replace texts;
  • 2.5) Click the Replace or Find button. See screenshot:

Batch Find and Replace dialog box

Notes:
1. If you click the Find button, all finding results will be displayed under the Preview Result tab. After previewing the results, if you want to replace all texts, please click the Find and Replace tab. Otherwise, close the dialog.

Batch Find and Replace dialog box - Find Result

2. If you click the Replace button, all specified texts will be replaced with new ones immediately, and the results will also be displayed under the Preview Result tab.

Batch Find and Replace dialog box - Replace Result

3. If you specify highlight colors in step 2, all replaced texts will be highlighted with specified colors, and you can easily find them at a glance in documents.

3. Close the Batch Find and Replace dialog box

Click here for more information about the Batch Find and Replace feature.

Kutools for Word is the ultimate Word add-in that streamlines your work and boosts your document processing skills. Get It Now!

Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

πŸ€– Kutools AI Features: Generate Content / Rewrite Text / Document Q&A / Get Quick Answers / Translate documents / Polish Document (Preserve Format)...

πŸ“˜ Document Mastery: Split Pages / Merge Documents / Export Selection in Various Formats (PDF/TXT/DOC/HTML...) / Batch Convert to PDF...

✏ Contents Editing: Batch Find and Replace across Multiple Files / Resize All Pictures / Transpose Table Rows and Columns / Convert Table to Text...

🧹 Effortless Clean: Sweap away Extra Spaces / Section Breaks / Text Boxes / Hyperlinks / For more removing tools, head to the Remove group...

βž• Creative Inserts: Insert Thousand Separators / Check Boxes / Radio Buttons / QR Code / Barcode / Multiple Pictures / Discover more in the Insert group...

πŸ” Precision Selections: Pinpoint Specific Pages / Tables / Shapes / Heading Paragraphs / Enhance navigation with more Select features...

⭐ Star Enhancements: Navigate to Any Location / Auto-Insert Repetitive Text / Toggle Between Document Windows / 11 Conversion Tools...

Kutools and Kutools Plus tabs on the Word Ribbon
πŸ‘‰ Want to try these features? Download Kutools for Word now! πŸš€
 

Best Office Productivity Tools

Kutools for Word - 100+ Tools for Word