Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 2.03 KB

Word.PageNumbers.Add.md

File metadata and controls

76 lines (47 loc) · 2.03 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
PageNumbers.Add method (Word)
vbawd10.chm159776869
vbawd10.chm159776869
Word.PageNumbers.Add
d8a81795-035b-9702-bcd4-02c302607670
06/08/2017
medium

PageNumbers.Add method (Word)

Returns a PageNumber object that represents page numbers added to a header or footer in a section.

Syntax

expression.Add (PageNumberAlignment, FirstPage)

expression Required. A variable that represents a PageNumbers object.

Parameters

Name Required/Optional Data type Description
PageNumberAlignment Optional Variant Can be any WdPageNumberAlignment constant.
FirstPage Optional Variant False to make the first-page header and the first-page footer different from the headers and footers on all subsequent pages in the document. If FirstPage is set to False, a page number isn't added to the first page. If this argument is omitted, the setting is controlled by the DifferentFirstPageHeaderFooter property.

Remarks

If the LinkToPrevious property for the HeaderFooter object is set to True, the page numbers will continue sequentially from one section to next throughout the document.

Example

This example adds a page number to the primary footer in the first section of the active document.

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

This example creates and formats page numbers in the header for the active document.

Set myPgNum = ActiveDocument.Sections(1) _ 
 .Headers(wdHeaderFooterPrimary) _ 
 .PageNumbers.Add(PageNumberAlignment:= _ 
 wdAlignPageNumberCenter, FirstPage:= True) 
myPgNum.Select 
With Selection.Range 
 .Italic = True 
 .Bold = True 
End With

See also

PageNumbers Collection Object

[!includeSupport and feedback]