Fix a Word 2016 Macro That Inserts Footer Content in the Header
Question details
Correct a recorded Word macro so header and footer content goes into the intended areas.

- Product
- Microsoft Word 2016
- Device & OS
- not provided
- Scenario
- A user records a macro to add content to a document's header and footer.
- Observed behavior
- Content intended for the footer may be inserted into the header because recorded navigation between header and footer layers is unreliable.
Identify which document section and header or footer type the macro should change. If you plan to edit VBA, make sure the Developer tab is available and review the recorded macro's existing navigation commands.
Edit the Macro to Use Explicit Header and Footer Ranges
Use explicit VBA ranges when the macro needs to place different content in the header and footer.
The example targets the primary header and footer in the document's first section. It replaces their existing contents, so adapt it if you need to preserve text, formatting, page numbers, or fields.
In Word, select Developer > Visual Basic. Open the module containing the recorded macro in the Project pane.
Replace the recorded header and footer navigation and insertion commands with explicit range assignments, adapting the text as needed: ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "Header text" ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = "Footer text"
Save the document as a Word Macro-Enabled Document (.docm), then select Developer > Macros, choose the macro, and select Run. Check the first section's header and footer.

Create a Word Template With Predefined Headers and Footers
Use a template when the same header and footer should appear in new documents without running a macro.
Create Documents With Headers and Footers in WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility, making it easier to move existing documents into WPS Writer. It does not fix Word's Macro Recorder behavior.

Frequently Asked Questions
Why does my recorded macro put footer text in the header?
Word's Macro Recorder may not reliably navigate between header and footer layers. Edit the macro in Developer > Visual Basic to reference the intended header and footer ranges directly.
Will the VBA example preserve existing page numbers?
No. Assigning text to a header or footer's Range.Text replaces its existing contents, including fields such as page numbers. Adapt the macro if those contents must be preserved.
How do I handle a different first-page header or footer?
Check the Different First Page setting in Word's header and footer tools. In VBA, target the first-page header or footer type rather than wdHeaderFooterPrimary when that is the area you need to change.
Can I avoid using a macro for repeated headers and footers?
Yes. Add the content through Insert > Header and Insert > Footer, then use File > Save As to save a Word Template (.dotx) for new documents.




