?
Solved

Word 2007 Macro That Removes Header and Footer?

Posted on 2011-05-10
2
Medium Priority
?
369 Views
Last Modified: 2012-05-11
Dear Experts,

I was wondering if someone would be kind enough to write me a simple Word 2007 Macro, which when run removes the header and footer from the word document that is open.

I hope this is not too much trouble. I will need help/advice on how to implement it, unfortunately I am not too great with coding in general.

Many Thanks,

0
Comment
Question by:ouch_mybrain_
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 35727297
A couple of points.

Firstly, this site is is intended to help by showing how to do it, not to do the work for you. However, this is a simple task and could be of interest to many.

Secondly, Word documents always have headers and footers. They can't be deleted. However they can be cleared of content.

Paste this code into a module of your template (probably the Normal template). Put the text cursor in the code and press F5 to run it.
Sub ClearHeadersText()
    Dim hdr As HeaderFooter
    Dim ftr As HeaderFooter
    Dim sec As Section
    Dim rng As Range
    
    For Each sec In ActiveDocument.Sections
        For Each hdr In sec.Headers
            Set rng = hdr.Range
            rng.Delete
        Next hdr
        For Each ftr In sec.Footers
            Set rng = ftr.Range
            rng.Delete
        Next ftr
    Next sec
End Sub

Open in new window

0
 

Author Closing Comment

by:ouch_mybrain_
ID: 35727325
Brilliant, thank you. it works. If it wasn't simple then I would not have asked, but point taken for future reference. Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question