L
LRL
I'm adding a button to a userform at runtime using the following code:
Private Sub UserForm_Activate()
Dim Mycmd As Control
Set Mycmd = Controls.Add("Forms.CommandButton.1", "CommandButton2",
Visible)
Mycmd.Left = 12
Mycmd.Top = 90
Mycmd.Width = 125
Mycmd.Height = 20
Mycmd.Caption = "unassigned"
End Sub
Private Sub CommandButton2_Click()
Dim i As Integer
i = 1
End Sub
I set a breakpoint in the CommandButton2_Click routine to see if
clicking actually works but the breakpoint is never hit.
How do I capture the click events for the button I add at runtime?
Thanks!
Private Sub UserForm_Activate()
Dim Mycmd As Control
Set Mycmd = Controls.Add("Forms.CommandButton.1", "CommandButton2",
Visible)
Mycmd.Left = 12
Mycmd.Top = 90
Mycmd.Width = 125
Mycmd.Height = 20
Mycmd.Caption = "unassigned"
End Sub
Private Sub CommandButton2_Click()
Dim i As Integer
i = 1
End Sub
I set a breakpoint in the CommandButton2_Click routine to see if
clicking actually works but the breakpoint is never hit.
How do I capture the click events for the button I add at runtime?
Thanks!