PageNumber Property

Microsoft Publisher Visual Basic

expression.PageNumber

expression    Required. An expression that returns one of the objects in the Applies To list.

Example

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