Written by Allen Wyatt (last updated December 21, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, and Word in Microsoft 365
Eppa needs to replace a company name in a document. The name appears throughout the document, and also in the header and footer. The document has multiple sections. Eppa can use Find and Replace to replace within the document itself, but it won't make replacements in the headers and footers for some reason. So, Eppa wonders if there is some setting that will cause Find and Replace to make the necessary replacements in the header and footer at the same time it does so in the document.
This is a more involved question that it may, at first, appear. Using Word on a Microsoft 365 installation, doing a simple text replacement using Find and Replace did exactly what Eppa wanted—it replaced the text in the main document and in the headers and footers.
If Word does not replace in the headers and footers for some reason, then there is a two-pass approach you can try out. Let's say that your document has an old company name ("Harris Electric") and that you want to replace that with a new company name ("Davis Services"). Follow these steps:
If you need to replace the company name in a lot of documents, then it may be better to use a macro. Here's an example of a macro that will make replacements in the main document and then in each header and footer in all the sections of the document:
Sub ReplaceInHeadersFooters()
    Dim sec As Section
    Dim hdr As HeaderFooter
    Dim ftr As HeaderFooter
    Dim rng As Range
    Dim findText As String
    Dim replaceText As String
    Dim StartMsg1 As String
    Dim StartMsg2 As String
    Dim EndMsg As String
    ' Set initial information
    StartMsg1 = "Enter the text to find:"
    StartMsg2 = "Enter the replacement text:"
    EndMsg = "Replacement completed in document, headers, and footers!"
    ' Set the text to find and replace
    findText = InputBox(StartMsg1, "Find Text")
    replaceText = InputBox(StartMsg2, "Replace Text")
    ' Replace in main document body
    Selection.HomeKey wdStory
    With Selection.Find
        .Text = findText
        .Replacement.Text = replaceText
        .Forward = True
        .Wrap = wdFindContinue
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ' Replace in headers and footers for each section
    For Each sec In ActiveDocument.Sections
        ' Loop through headers
        For Each hdr In sec.Headers
            If hdr.Exists Then
                Set rng = hdr.Range
                With rng.Find
                    .Text = findText
                    .Replacement.Text = replaceText
                    .Forward = True
                    .Wrap = wdFindContinue
                    .Execute Replace:=wdReplaceAll
                End With
            End If
        Next
        ' Loop through footers
        For Each ftr In sec.Footers
            If ftr.Exists Then
                Set rng = ftr.Range
                With rng.Find
                    .Text = findText
                    .Replacement.Text = replaceText
                    .Forward = True
                    .Wrap = wdFindContinue
                    .Execute Replace:=wdReplaceAll
                End With
            End If
        Next
    Next
   MsgBox EndMsg, vbInformation
End Sub
Run the document and you can enter what you want to find and what you want to replace it with. If you need the finding and replacing to be case sensitive, then add the following to each iteration of the Find and Replace, just before the setting of the .Forward property:
        .MatchCase = True
                Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (7538) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, and Word in Microsoft 365.
 
                        Discover the Power of Microsoft Office This beginner-friendly guide reveals the expert tips and strategies you need to skyrocket your productivity and use Office 365 like a pro. Mastering software like Word, Excel, and PowerPoint is essential to be more efficient and advance your career. Simple lessons guide you through every step, providing the knowledge you need to get started. Check out Microsoft Office 365 For Beginners today!
Word allows you to search for specific ASCII codes in a document. If you use codes to search for alphabetic characters, ...
Discover MoreNeed to find all the instances of a particular word and change the formatting of those instances? It's easy to do using ...
Discover MoreWant to change the order of the day and month in a date? This tip shows you how you can do so using the Find and Replace ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-12-23 15:28:22
Kevin Swan
I'm not sure if this still works but I seem to remember that if you do a Ctrl-A (Select All) and then do the Find & Replace, it does the main document and the headers and footers. It might only work in draft view mode?
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments