| Part | Description | |
| object | Required. A valid object. | |
| Boolean | Optional. Specifies whether a control takes the focus when clicked. | |
| Value | Description | |
| True | The button takes the focus when clicked (default). | |
| False | The button does not take the focus when clicked. | |
Private Sub CommandButton1_Click()
MsgBox "Watch CommandButton1 to see if it takes the focus."
End Sub
Private Sub ToggleButton1_Click()
If ToggleButton1 = True Then
CommandButton1.TakeFocusOnClick = True
ToggleButton1.Caption = "TakeFocusOnClick On"
Else
CommandButton1.TakeFocusOnClick = False
ToggleButton1.Caption = "TakeFocusOnClick Off"
End If
End Sub
Private Sub UserForm_Initialize()
CommandButton1.Caption = "Show Message"
ToggleButton1.Caption = "TakeFocusOnClick On"
ToggleButton1.Value = True
ToggleButton1.Width = 90
End Sub