Share via


FindByPageID Method [Publisher 2003 VBA Language Reference]

Returns a Page object that represents the page with the specified page ID number. Each page is automatically assigned a unique ID number when it's created. Use the PageID property to return a page's ID number.

expression.FindByPageID(PageID)

expression Required. An expression that returns a Pages collection.

PageID  Required Long. Specifies the ID number of the page you want to return. Publisher assigns this number when the page is created.

Remarks

Unlike the PageIndex property, the PageID property of a Page object won't change when you add pages to or rearrange pages in the publication. Therefore, using the FindByPageID method with the page ID number can be a more reliable way to return a specific Page object from a Pages collection than using the Item method with the page's index number.

Example

This example demonstrates how to retrieve the unique ID number for a Page object and then use this number to return that Page object from the Pages collection and add a new shape to the page.

Sub FindPage()
    Dim lngPageID As Long

    'Get page ID
    lngPageID = ActiveDocument.Pages.Add(Count:=1, After:=1).PageID

    'Use page ID to add a new shape to the page
    ActiveDocument.Pages.FindByPageID(PageID:=lngPageID) _
        .Shapes.AddShape Type:=msoShape5pointStar, _
        Left:=200, Top:=72, Width:=50, Height:=50

End Sub

Applies to | MasterPages Collection | Pages Collection