Thursday, October 22, 2009

MS Word - Delete All Headers and Footers

Repetitious, time-consuming tasks are always a prime candidate for macros; this is no exception. The following macro will zip right through each section of a document, deleting all the headers and footers that have been defined.

Sub RemoveHeadAndFoot()
Dim oSec As Section
Dim oHead As HeaderFooter
Dim oFoot As HeaderFooter

For Each oSec In ActiveDocument.Sections
For Each oHead In oSec.Headers
If oHead.Exists Then oHead.Range.Delete
Next oHead

For Each oFoot In oSec.Footers
If oFoot.Exists Then oFoot.Range.Delete
Next oFoot
Next oSec
End Sub