HeaderFooter Object

Excel Developer Reference

Represents a single header or footer. The HeaderFooter object is a member of the HeadersFooters collection.

Version Information
 Version Added:  Excel 2007

Remarks

You can also return a single HeaderFooter object by using the HeaderFooter property with a Selection object.

Bb224228.vs_note(en-us,office.12).gif  Note
You cannot add HeaderFooter objects to the HeadersFooters collection.

Use the DifferentFirstPageHeaderFooter property with the PageSetup object to specify a different first page.

Example

The following example adds the date and time to the center header in the active worksheet.

Visual Basic for Applications
  With ActiveSheet.PageSetup
    .CenterHeader = "&D&T"
    .OddAndEvenPagesHeaderFooter = False
    .DifferentFirstPageHeaderFooter = False
    .ScaleWithDocHeaderFooter = True
    .AlignMarginsHeaderFooter = True
End With

See Also