Table of contents
TOC
Collapse the table of content
Expand the table of content

TextRange.InsertPageNumber Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
|
3 Contributors

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

NameRequired/OptionalData TypeDescription
TypeOptionalPbPageNumberTypeSpecifies whether the page number is the current page number or the next or previous page number of a linked text box.

Return Value

TextRange

Remarks

Type can be one of these PbPageNumberType constants.

ConstantDescription
pbPageNumberCurrentThe default.
pbPageNumberNextInStoryInserts the page number of the next linked text box.
pbPageNumberPreviousInStoryInserts the page number of the previous linked text box.

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
© 2018 Microsoft