A ToggleButton named ToggleButton1.
Private Sub UserForm_Initialize()
CommandButton1.Caption = "Move current control"
CommandButton1.AutoSize = True
CommandButton1.TakeFocusOnClick = False
ToggleButton1.Caption = "Use Layout Event"
ToggleButton1.Value = True
End Sub
Private Sub CommandButton1_Click()
If ActiveControl.Name = "ToggleButton1" Then
'Keep it stationary
Else
'Move the control, using Layout event when ToggleButton1.Value is True
ActiveControl.Move 0, 0, , , ToggleButton1.Value
End If
End Sub
Private Sub UserForm_Layout()
Dim MyControl As Control
MsgBox "In the Layout Event"
'Find the control that is moving.
For Each MyControl In Controls
If MyControl.LayoutEffect = fmLayoutEffectInitiate Then
MsgBox MyControl.Name & " is moving."
Exit For
End If
Next
End Sub
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
ToggleButton1.Caption = "Use Layout Event"
Else
ToggleButton1.Caption = "No Layout Event"
End If
End Sub