Access a Page in a MultiPage Control

The following example accesses an individual page of a MultiPage in several ways:

  • Using the Pages collection with a numeric index.

  • Using the name of the individual page in the MultiPage.

  • Using the SelectedItem property.

To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains a MultiPage named MultiPage1 and a CommandButton named CommandButton1.

Sub CommandButton1_Click 
 Dim PageName 
 Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").MultiPage1 
 
 For i = 0 To MultiPage1.Count - 1 
 'Use index (numeric or string) 
 MsgBox "MultiPage1.Pages(i).Caption = " & MultiPage1.Pages(i).Caption 
 MsgBox "MultiPage1.Pages.Item(i).Caption = " & MultiPage1.Pages.Item(i).Caption 
 
 'Use Page object without referring to Pages collection 
 If i = 0 Then 
 MsgBox "MultiPage1.Page1.Caption = " & MultiPage1.Page1.Caption 
 ElseIf i = 1 Then 
 MsgBox "MultiPage1.Page2.Caption = " & MultiPage1.Page2.Caption 
 End If 
 
 'Use SelectedItem Property 
 MultiPage1.Value = i 
 MsgBox "MultiPage1.SelectedItem.Caption = " & MultiPage1.SelectedItem.Caption 
 Next 
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.