Name Property Example

Name Property Example

The following example displays the Name property of each control on a form. This example uses the Controls collection to cycle through all the controls placed directly on the User form.

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

Sub CommandButton1_Click()
    Set Controls = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls
    For i = 0 to Controls.Count - 1
        MsgBox "MyControl.Name = " & Controls.Item(i).Name
    Next
End Sub