Exists Property

Microsoft Word Visual Basic

True if the specified HeaderFooter object exists. Read/write Boolean.

Note  The primary header and footer exist in all new documents by default. Use this method to determine whether a first-page or odd-page header or footer exists. You can also use the DifferentFirstPageHeaderFooter or OddAndEvenPagesHeaderFooter property to return or set the number of headers and footers in the specified document or section.

Example

If a first-page header exists in section one, this example sets the text for the header.

Dim secTemp As Section

Set secTemp = ActiveDocument.Sections(1)
If secTemp.Headers(wdHeaderFooterFirstPage).Exists = True Then
    secTemp.Headers(wdHeaderFooterFirstPage).Range.Text = _
        "First Page"
End If