Word: Deleting all headers and footers

From https://answers.microsoft.com/en-us/msoffice/forum/all/vba-removingdeleting-all-headers-in-a-document/b1d35528-a2e2-46d3-b3fa-bfcc98ba2805

Sub RemoveHeadersFooters()

    Dim sec As Section

    Dim hdr As HeaderFooter

    For Each sec In ActiveDocument.Sections

        For Each hdr In sec.Headers

            If hdr.Exists Then

                hdr.Range.Delete

            End If

        Next hdr

        For Each hdr In sec.Footers

            If hdr.Exists Then

                hdr.Range.Delete

            End If

        Next hdr

    Next sec

End Sub