Skip to main content

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


Find and replace same text in Word document with the Find and Replace 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.


Find and replace same text only in the header and footer section with the VBA code

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.


Find and replace different texts at the same time with an awesome feature

The Batch Find and Replace feature of Kutools for Word can help to easily find and replace different texts in a document or across multiple documents at the same time.

Before apply this feature, please take minutes to download and install it firstly.

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.

  If you want to have a free trial (60-day) of this utility, please click to download it, and then go to apply the operation according above steps.


Related articles

Find and replace multiple words at the same time in a Word document
Word provides a Find and Replace function to find all instances of a word or phrase and replace them with a new word at the same time. But if you want to find and replace different words at the same time, this build-in function can’t help. In this article, we are talking about a VBA method to find and replace multiple different words at the same time in Word document.

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.

Replace hard returns with soft returns in Word
If you want to format a Word document by replacing paragraph marks (hard returns) with manual line breaks (soft returns) in it. How can you do to replace hard returns with soft returns in Word quickly? This tutorial will show you several ways to convert hard returns to soft returns.

Replace soft returns with hard returns in Word
If you want to format a Word document by replacing manual line breaks (soft returns) with paragraph marks (hard returns) in it. How can you do to replace soft returns with hard returns in Word quickly? This tutorial will show you several ways to convert soft returns to hard returns.


Recommended Word Productivity Tools

 

Kutools For Word - More Than 100 Advanced Features For Microsoft Word, Save Your 50% Time

  • 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...
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations