Find and replace texts in Word document, header and footer
Normally, the Find & Replace function can help to find and replace specific text in a Word document’s body, header and footer at the same time. Have you ever tried to find and replace texts only in the header and footer section in a Word document? Or to find and replace multiple different texts at the same time in a word document or across multiple documents? This tutorial shows some methods to achieve them.
Find and replace same text in Word document with the Find and Replace feature
Find and replace same text only in the header and footer section with the VBA code
Find and replace different texts at the same time with an awesome feature
It is easy to use the Find and Replace feature in Word document.
1. Open the document containing the words you want to replace, press the Ctrl + H keys at the same time to open the Find and Replace dialog box.
2. In the Find and Replace dialog box, under the Replace tab, enter the old text and the new text separately into the Find what and Replace with boxes, and then click the Replace All button. See screenshot:
Note: You can click the More button to find more search options as you need.
3. Then a dialog pops up to show you how many replacements have been made. Click OK to finish.
If you only want to find and replace in the header and footer of a document, method in this section can help.
1. Open the document you will find and replace text in the header and footer, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module, and then copy the below VBA code into the Module window.
VBA code: Find and replace text only in header and footer
Sub FindAndReplaceOfHeaderAndFooter() 'Update by Extendoffice 20190805 Dim xDoc As Document Dim xSelection As Selection Dim xSec As Section Dim xHeader As HeaderFooter Dim xFooter As HeaderFooter On Error Resume Next Set xDoc = Application.ActiveDocument For Each xSec In xDoc.Sections For Each xHeader In xSec.Headers xHeader.Range.Select Set xSelection = xDoc.Application.Selection With xSelection.Find .Text = "I've found header text" 'Enter the old header text here! .Replacement.Text = "I've found header text" 'Enter the new header text here! .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next xHeader For Each xFooter In xSec.Footers xFooter.Range.Select Set xSelection = xDoc.Application.Selection With xSelection.Find .Text = "I've found footer text" 'Enter the old footer text here! .Replacement.Text = "I've found footer text" 'Enter the old footer text here! .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next xFooter Next xSec xDoc.ActiveWindow.ActivePane.Close If xDoc.ActiveWindow.View.SplitSpecial = wdPaneNone Then xDoc.ActiveWindow.View.Type = wdPrintView Else xDoc.ActiveWindow.View.Type = wdPrintView End If xDoc.Activate End Sub
Note: In the code, please replace the “Find header text” and the “Find footer text” with the texts you want to find in header and footer; and replace the “I’ve found header text” and “I’ve found footer text” with the new header text and footer text.
3. Press the F5 key to run the code. Then the specific texts in header and footer are replaced with new texts.
1. Launch the Microsoft Word application, click Kutools Plus > Batch Find and Replace.
2. In the Batch Find and Replace window, you need to do as follows.
- 2.1 click the button > Add File or Add Folder to add the documents that you need to find and replace texts inside.
- 2.2 Click the Add row button to insert the find and replace fields. If you want to find and replace three different texts at the same time, please create three rows.
- 2.3 In each row, enter the existing texts you will replace with a new one in the Find column, and then enter the new text into the Replace column.
- 2.4 Specify the Search Type for each row.
- 2.5 In the Find in column, choose where to apply the find and replace. It includes Main document, Header and Footer in this section. You can choose one of them, two of them or all of them based on your needs.
- 2.6. Click the Replace button to start the operation. See screenshot:
Then all specific texts are replaced across selected documents.
Tip: You can highlight the result with background color by specifying certain color in the Highlight column for a row.
Recommended Word Productivity Tools
- Complicated and repeated operations can be done one-time processing in seconds.
- Insert multiple images across folders into Word document at once.
- Merge and combine multiple Word files across folders into one with your desired order.
- Split the current document into separate documents according to heading 1, section break or other criteria.
- Convert files between Doc and Docx, Docx and PDF, collection of tools for common conversions and selection, and so on...