Part | Description | |
object | Required. A valid object. | |
collectionindex | Required. A member's position, or index, within a collection. |
Dim MyControl As Object
Dim ControlsIndex As Integer
Private Sub CommandButton1_Click()
If OptionButton1.Value = True Then
'Process Controls collection for UserForm
Set MyControl = Controls.Item(ControlsIndex)
Label1.Caption = MyControl.Name
'Prepare index for next control on Userform
ControlsIndex = ControlsIndex + 1
If ControlsIndex >= Controls.Count Then
ControlsIndex = 0
End If
ElseIf OptionButton2.Value = True Then
'Process Current Page of Pages collection
Set MyControl = MultiPage1.Pages.Item(MultiPage1.Value)
Label1.Caption = MyControl.Name
End If
End Sub
Private Sub UserForm_Initialize()
ControlsIndex = 0
'TabsIndex = 0
OptionButton1.Caption = "Controls Collection"
OptionButton2.Caption = "Pages Collection"
OptionButton1.Value = True
CommandButton1.Caption = "Get Member Name"
End Sub