How to print word document without header and footer?
To print a Word document without headers and footers, you can use the following VBA code:
- Press ALT + F11 to open the Microsoft Visual Basic for Applications window.
- Click Insert > Module, then copy and paste the following code into the empty module:
Sub PrintDocWithoutHeaderFooter()
Call SetHeaderAndFooter(True)
Options.PrintHiddenText = False
Dialogs(wdDialogFilePrint).Show
Call SetHeaderAndFooter(False)
End Sub
Sub SetHeaderAndFooter(xBool As Boolean)
Dim xSection As Section
For Each xSection In ActiveDocument.Sections
xSection.Headers(wdHeaderFooterEvenPages).Range.Font.Hidden = xBool
xSection.Headers(wdHeaderFooterFirstPage).Range.Font.Hidden = xBool
xSection.Headers(wdHeaderFooterPrimary).Range.Font.Hidden = xBool
xSection.Footers(wdHeaderFooterEvenPages).Range.Font.Hidden = xBool
xSection.Footers(wdHeaderFooterFirstPage).Range.Font.Hidden = xBool
xSection.Footers(wdHeaderFooterPrimary).Range.Font.Hidden = xBool
Next xSection
End Sub
- After inserting the code, press F5 to run the code. The Print dialog will appear, and you can configure the print settings according to your needs, as shown in the image below:
- Click OK to start printing, and the document will be printed without headers and footers.