Class HeadersFooters (Word VBA)

A collection of HeaderFooter objects that represent the headers or footers in the specified section of a document. To use a HeadersFooters class variable it first needs to be instantiated, for example


Dim hfs as HeadersFooters
Set hfs = ActiveDocument.Range.Sections(1).Headers

Count

Returns a Long that represents the number of headers and/or footers in the collection.


Dim lngCount As Long
lngCount = ActiveDocument.Range.Sections(1).Headers.Count

Item

Returns a HeaderFooter object that represents a header or footer in a range or section.

Item (Index)

Index: A constant that specifies the header or footer in the range or section.


Sub HeadFootItem() 
 ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True 
 With ActiveDocument.Sections(1).Headers _ 
 .Item(wdHeaderFooterFirstPage).Range 
 .InsertBefore "Sales Report" 
 With .Font 
 .Bold = True 
 .Size = "15" 
 .Color = wdColorBlue 
 End With 
 .Paragraphs.Alignment = wdAlignParagraphCenter 
 End With 
End Sub