PDA

View Full Version : Insert / Remove Header and Footer



mturnbull
10-27-2005, 09:59 AM
Can anyone help with code to remove the header and footer from a document, either section by section or document wide?
Ta
mturnbull:help

JohnnyBravo
10-27-2005, 12:09 PM
Mturnbull,

I'm very new to VBA as well but something like that should be quite easy to do using the built in macro recorder in MSWord. It's under the 'Tools' menu. This should get you started - perhaps another moderator or senior forum member can come up with a better one.

Sub ClearHeaderFooter()
'
' ClearHeaderFooter Macro
' Macro recorded 10/27/2005 by JohnnyBravo
'
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub