TextRange.InsertPageNumber method (Publisher)

Returns a TextRange object that represents a page number field in a publication.

Syntax

expression.InsertPageNumber (Type)

expression A variable that represents a TextRange object.

Parameters

Name Required/Optional Data type Description
Type Optional PbPageNumberType Specifies whether the page number is the current page number or the next or previous page number of a linked text box. Can be one of the PbPageNumberType constants.

Return value

TextRange

Example

This example inserts a page number field in a shape on the master page so that the current page number appears at the top of each page.

Sub PageNumberShape() 
 With ActiveDocument.MasterPages(1).Shapes _ 
 .AddShape(Type:=msoShape5pointStar, Left:=36, _ 
 Top:=36, Width:=50, Height:=50) 
 With .TextFrame.TextRange 
 .InsertPageNumber 
 .ParagraphFormat.Alignment = pbParagraphAlignmentCenter 
 End With 
 .Fill.ForeColor.RGB = RGB(Red:=125, Green:=125, Blue:=255) 
 End With 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.