How to search and replace across multiple files in word?
If you have several dozen word files which contain the same content (such as Header, footer, some special words or number), and you need to replace the same content across those documents in Word. How would it be easier for you to get it done quickly? Certainly, you can open those files one by one to replace the same content, but it will be time-consuming and troublesome. This tutorial will show you a tricky way to replace same content within multiple documents in Word at once.
Office Tab: Enable Tabbed Editing and Browsing in Office, Just Like Chrome, Firefox, IE 8/9/10.
Classic Menu for Office: Bring Old Look of Office 2003 Back to Office 2007, 2010 and 2013.
Using a VBA for searching and replacing same content across multiple documents at one time in Word:
Step 1: Press “Alt-F11” to open the Microsoft Visual Basic for Application window;
Step 2: Click Module on the Insert tab, copy and paste the following VBA code into the Module window;
Step 3: Then click Run button to apply the VBA.
VBA: searching and replacing same content across multiple documents at one time
Dim MyDialog As FileDialog, GetStr(1 To 100) As String '100 files is the maximum applying this code
On Error Resume Next
Set MyDialog = Application.FileDialog(msoFileDialogFilePicker)
.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
i = i - 1
Application.ScreenUpdating = False
For j = 1 To i Step 1
Set Doc = Documents.Open(FileName:=GetStr(j), Visible:=True)
.Text = "search" 'Find What
.Replacement.Text = "find" 'Replace With
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Application.ScreenUpdating = True
MsgBox "operation end, please view", vbInformation
Note:you can change the Text = "search”, Replacement.Text = "find” to specify the content to be searched and the content to be applied for replacement.
Kutools for Word
More than 100 Advanced Functions for Word 2003, 2007, 2010 and 2013