How to search and replace across multiple files in Word?
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.
- Press Alt + F11 to open the Microsoft Visual Basic for Applications window.
- 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
- Press F5 to run the code.
- In the Browse window, select the documents in which you want to find and replace text, then click OK.
- In the first Kutools for Word dialog box, enter the text you want to find in the Find what field and click OK.
- In the second Kutools for Word dialog box, enter the text you want to replace it with and click OK.
- Click OK in the final Microsoft Word dialog box to finish the process.
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.
1. Please click Kutools Plus > Batch Find and Replace to enable the feature.
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:
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 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:
3. Close the Batch Find and Replace dialog box
Click here for more information about the Batch Find and Replace feature.
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...
Best Office Productivity Tools
Kutools for Word - 100+ Tools for Word
- π€ Kutools AI Features: Generate, Rewrite, Summarize, Translate Documents / Get Quick Answers / Polish Document (Preserve Format)
- π Document Mastery: Split Pages / Merge Documents / Batch Convert to PDF
- β Contents Editing: Batch Find and Replace / Resize All Pictures
- π§Ή Effortless Clean: Remove Extra Spaces / Remove Section Breaks
- β Creative Inserts: Insert Thousand Separators / Insert Check Boxes / Create QR Codes