Share via


PageNumber Object

PageNumbers
PageNumber

Represents a page number in a header or footer. The PageNumber object is a member of the PageNumbers collection. The PageNumbers collection includes all the page numbers in a single header or footer.

Using the PageNumber Object

Use PageNumbers(index), where index is the index number, to return a single PageNumber object. In most cases, a header or footer will contain only one page number, which is index number 1. The following example centers the first page number in the primary header in section one in the active document.

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary) _
    .PageNumbers(1).Alignment = wdAlignPageNumberCenter

Use the Add method to add a page number (a PAGE field) to a header or footer. The following example adds a page number to the primary footer in the first section and in any subsequent sections. The page number doesn't appear on the first page.

With ActiveDocument.Sections(1)
    .Footers(wdHeaderFooterPrimary).PageNumbers.Add _
        PageNumberAlignment:=wdAlignPageNumberLeft, _
        FirstPage:=False
End With

Properties | Alignment Property | Application Property | Creator Property | Index Property | Parent Property

Methods | Copy Method | Cut Method | Delete Method | Select Method

Parent Objects

Child Objects