Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Deleting All Headers and Footers.

Deleting All Headers and Footers

by Allen Wyatt
(last updated April 2, 2011)

14

If you work with documents you receive from other people, one of the tasks you may routinely need to do is delete all the headers and footers in the documents. One way to do this is to simply select the various headers and footers and delete them, but if the document contains many sections, doing so can be very time consuming. (Particularly if you consider that each section can have up to three different 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

This macro is very powerful—it doesn't ask if you want to proceed, nor does it consider what may be included in the headers and footers. It simply deletes them all, leaving your document with none. If you regularly process quite a few documents, you can easily assign the macro to a toolbar button, menu item, or shortcut key.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1777) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Deleting All Headers and Footers.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Adding Text to an Envelope

Need to customize the way that Word prints envelopes? There are a couple of approaches you can use, as discussed in this tip.

Discover More

Losing Data in a Shared Workbook

When you create a shared workbook, you run the risk of losing some of the data in that workbook. Here's a discussion ...

Discover More

Adding Text to a Drawing Shape

You can add text to all sorts of drawing shapes, not just text boxes. Here's how easy it is.

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (menu)

Editing Headers and Footers

Headers and footers are a nice final touch in a document. You can easily edit them by using the methods described in this ...

Discover More

Using Last-page Headers and Footers

Headers and footers add a nice touch to your documents, particularly if they are printed. You may want Word to use a ...

Discover More

Suppressing Headers or Footers

Don't want a header or footer to appear on just a portion of your document? It's easy to do when you understand that ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is eight minus 1?

2017-02-14 10:33:02

Joe

This worked great for some of my documents, but now it is saying "Method 'Range' or Object 'HeaderFooter' failed"
Then it gives me the option to End or Debug, neither of which seem to do what I want.

Any idea as to what this might mean or what I could do about it?


2016-11-18 01:44:02

Taisho

To prevent type mismatch 13 error, define oHead and oFoot as objects instead of HeaderFooter.


2016-10-20 16:59:10

dirst

deleting all the headers and footers that have been defined === defined??? where, how??? i ran it. no result.


2016-08-27 00:40:52

Manikandan

Really awesome! I have finished my work very easily within minutes for 1000 pages.


2015-03-27 03:48:01

Kumar

Hi, Thanks for your Code. it's works Perfectly for all pages. i have to deleted footer for selected page. i have tried to achieve it but i can't. I Would really appreciate your help if you are able to do it for me


2014-06-23 00:57:12

Sally NZ

Thanks for the code but I only want to delete headers and footers on the first page. I tried to modify your code using:
the constant wdHeaderFooterFirstPage but I haven't got it right and can't get it to work.
Would appreciate your help if you are able to give it. Many thanks.


2013-04-19 13:56:43

George M Lee

The macro works great but it deletes my page numbers too. Any way to modify so the page numbers don't delete?


2013-02-21 18:17:39

Andrew Burt

Thanks for the code! I did find one small issue, namely if a header/footer has a text box in it, then your code doesn't catch it. I had a devil of a time figuring out how to delete those too. After some digging I found adding this--

Dim oShape As Shape

For Each oShape In oHead.Shapes
oShape.Delete
Next oShape

--inside each of your loops, above the "If oHead.Exists Then oHead.Range.Delete", line did the trick. (Likewise for 'foot')

Figured you might want to add that for completeness. Thanks!


2012-11-20 11:03:08

awyatt

On which line do you get the error, Dom?


2012-11-20 10:53:20

Dom

This looks brilliant and exactly what I need. Unfortunately I get a Run time error '13': Type Mismatch

Any idea why this might be? I'm opening documents (Word 2003 & Word 2007) from Excel 2007 and running the macro from there.

Thanks


2012-11-08 06:10:28

Franco

Works great!!! Good job.
Thank you very much


2012-07-22 07:35:14

João Carlos

Thank you so much!


2012-07-13 14:38:58

Chey

Desparately need to do this now on an important document but have never run a macro. How do I do this?


2012-01-09 11:43:33

KP

It worked... Thanks!


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.