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

Defining a Name

One of the great features of Excel is that it allows you to use named ranges. These can make your formulas much easier to ...

Discover More

Opening Sites in a Browser

You can store all sorts of information in a worksheet, including Web addresses. If you want to open those addresses in a ...

Discover More

Counting Precedents and Dependents

Do you need to know how many precedents or dependents there are on a worksheet? You could count them manually, or you could ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

MORE WORDTIPS (MENU)

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 special ...

Discover More

Including Headers and Footers when Selecting All

If you are creating a macro that, in the course of processing your document, needs to update all the fields in the document, ...

Discover More

Protecting Headers and Footers

If you don't want the information in a header of footer to be changed by users of your document, there are a couple of things ...

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 for this tip:

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. 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 8 - 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!


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.

Links and Sharing
Share