#1
|
|||
|
|||
New to Macros: Cannot remove Header/Footer: MS Word
I have managed not to need how to use macros all of these years, until finding out that I have this magical header which is only magical because I've done everything that I know to remove it and it remains, now I have other issues because I have been playing with the developer settings. Another element to MS Word that I have never known about (all these years!).
I used the remove macro found online on a YouTube video, however the steps that was shown were not exactly the steps I used, because something didn't work out as I entered the macro script to visual basic, then I guess I was supposed to exit and return to the Word document, then to click on the macro-option and click run. Nothing happens when I do this. Macro Code: Code:
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 The book is 900 pages, and in order to get the formatting correct for digital printing and paper back, I really need to remove the headers and footer so I can get the pages the way they are supposed to be in the published format. All help is greatly appreciated! Thank you so much!! |
#2
|
|||
|
|||
Sounds to me like you may simply be entering your code in the wrong place. Hard to tell by your question. But I just did a quick test with your code and it worked on a small 2 page document, so it may work for you.
To use your script, try these steps...
|
#3
|
||||
|
||||
All you should need is:
Code:
Sub RemoveHeadAndFoot() Application.ScreenUpdating = False Dim Sctn As Section, HdFt As HeaderFooter For Each Sctn In ActiveDocument.Sections For Each HdFt In Sctn.Headers With HdFt If .Exists = True Then .Range.Text = vbNullString End With Next For Each HdFt In Sctn.Footers With HdFt If .Exists = True Then .Range.Text = vbNullString End With Next Next End Sub For Mac macro installation & usage instructions, see: Word:mac - Install a Macro
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
footer, header, macro word |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to remove 'header' 'footer' labels? | abrogard | Word | 2 | 05-15-2022 06:50 PM |
Adding text to the header and footer without removing all other content in the header and footer | digitalelise | Word VBA | 2 | 10-23-2019 02:58 AM |
Add, Resize & Relocate Header & Footer with Macros | Sarah123 | Word VBA | 11 | 11-13-2018 07:15 AM |
Can't remove header & footer formatting ... | frangipan | Word | 2 | 07-11-2014 12:27 PM |
How do I remove header and footer | captn1 | Word | 2 | 09-04-2010 04:14 PM |