VBA: removing/deleting all headers in a document

I need the VBA code to remove all of the headers in a document.
Answer
Answer

Try this:

 

Sub RemoveHeaders()
    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
    Next sec
End Sub

---
Best wishes, HansV
https://www.eileenslounge.com

3 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated February 28, 2024 Views 894 Applies to: