Page.PageNumber Property (Publisher)

Returns a String that represents the current page number. Read-only.


expression. PageNumber

expression A variable that represents a Page object.

Return value



This example creates a text box, gets the current page number, and inserts it with new text into the new shape.

Sub GetPageNumber() 
 Dim strPageNumber As String 
 With ActiveDocument.Pages(1) 
 strPageNumber = .PageNumber 
 .Shapes.AddTextbox(Orientation:=pbTextOrientationHorizontal, _ 
 Left:=100, Top:=100, Width:=100, Height:=100) _ 
 .TextFrame.TextRange.InsertAfter NewText:="This is page " _ 
 & strPageNumber & " of " & .Parent.Count & "." 
 End With 
End Sub