Skip to main content

Kutools for Office β€” One Suite. Five Tools. Get More Done.

How to search and replace across multiple files in Word?

Author Amanda Li Last modified

If you have dozens of Word files containing the same content (like headers, footers, or specific text), and you need to replace this content across all documents, doing it manually can be tedious. This tutorial introduces two methods to quickly replace the same or different content across multiple Word documents at once.

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 shows how to use VBA code to search for and replace content across multiple documents simultaneously.

  1. Press Alt + F11 to open the Microsoft Visual Basic for Applications window.
  2. Click "Insert" > "Module", then paste the following code:
    Sub CommandButton1_Click()
    'Updated by Extendoffice 20180625
    Dim xFileDialog As FileDialog, GetStr(1 To 100) As String
    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
                .Replacement.Text = xReplaceStr
                .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
            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 you want to process, then click "OK".
    Browse window
  5. In the "Find what" input box, enter the word or phrase to find and click "OK".
    Find what box
  6. In the "Replace with" input box, enter the replacement text and click "OK".
    Replace with box
  7. Click "OK" in the final Microsoft Word dialog box.
    Confirmation dialog

All instances of the specified text in the selected Word files will be replaced at once.


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

The "Batch Find and Replace" feature in Kutools for Word lets you search and replace multiple text items across several Word documents at once.

Kutools for Word, equipped with AI πŸ€–, offers over 100 handy features to simplify your tasks.
  1. Click "Kutools" > "Batch Replacement".
    Batch Replacement button
  2. In the Batch Find and Replace dialog, configure the settings:
    1. Click the "Add Row" button.
    2. In the new row:
      1. Enter the text to find under "Find".
      2. Enter the replacement text under "Replace".
      3. Optionally, specify a search type, location where to find and replace, highlight color, and other options as needed in the respective columns.
    3. Click the Add button button in the "File Type" section to add Word files to the batch.
    4. Click "Replace" or "Find".
      Tip: Repeat steps 1) and 2) to add more find-and-replace rules.
      Batch Find and Replace configuration
  3. Close the Batch Find and Replace dialog when done.

Notes:

  • If you click "Find", the matches will appear under the "Preview Result" tab. To apply replacements afterward, switch back to the "Find and Replace" tab.
  • If you click "Replace", all matches are immediately replaced and shown under "Preview Result".
  • If highlight colors were specified, the replacements in your Word documents will be color-coded accordingly.

For more information about the "Batch Find and Replace" feature, view the tutorial page.

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: AI Assistant / Real-Time Assistant / Super Polish (Preserve Format) / Super Translate (Preserve Format) / AI Redaction / AI Proofread...

πŸ“˜ 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...

🌍 Supports 40+ Languages: Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

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

✨ Kutools for Office – One Installation, Five Powerful Tools!

Includes Office Tab Pro Β· Kutools for Excel Β· Kutools for Outlook Β· Kutools for Word Β· Kutools for PowerPoint

πŸ“¦ Get all 5 tools in one suite | πŸ”— Seamless integration with Microsoft Office | ⚑ Save time and boost productivity instantly

Best Office Productivity Tools

Kutools for Word - 100+ Tools for Word