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

Converting Text to Uppercase in a Macro

Macros are often used to process documents. If part of the processing involves making text selections uppercase, Word ...

Discover More

Updating Fields in Locked Forms

Updating form fields in Word can be confusing, especially when the fields are locked in a form. This tips explains why the ...

Discover More

Adjusting Space Before

If you need to adjust the space that appears before a paragraph, there are several ways you can approach the adjustment. Here ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (menu)

Missing Header and Footer Toolbar

When you need to make changes to the header or footer of a document, the Header and Footer toolbar is invaluable. What if you ...

Discover More

Changing Headers and Footers

Editing what is in your page header or footer is fairly easy, and you can use the same editing techniques you already know. ...

Discover More

Insert AutoText Tool Unavailable on Header and Footer Toolbar

When creating headers or footers, you might notice at some time that the "Insert AutoText" tool on the Header and Footer ...

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 8Mpixels. 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 6 - 3?

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.