R
Russell W. Patterson
Y'all:
I am trying to add a control at run time on my user form. Using Excel
2002. If you go into the visual basic help and search on
"control.add" the very first item in the returned list is "AddControl
Event". The example that is given for the AddControl Event won't run
for me. I pasted it below. WHat is wrong with it?
russ
(e-mail address removed)
Dim Mycmd as Control
Private Sub CommandButton1_Click()
Set Mycmd = Controls.Add("MSForms.CommandButton.1") ',
CommandButton2, Visible)
Mycmd.Left = 18
Mycmd.Top = 150
Mycmd.Width = 175
Mycmd.Height = 20
Mycmd.Caption = "This is fun." & Mycmd.Name
End Sub
Private Sub UserForm_AddControl(ByVal Control As _
MSForms.Control)
Label1.Caption = "Control was Added."
End Sub
I am trying to add a control at run time on my user form. Using Excel
2002. If you go into the visual basic help and search on
"control.add" the very first item in the returned list is "AddControl
Event". The example that is given for the AddControl Event won't run
for me. I pasted it below. WHat is wrong with it?
russ
(e-mail address removed)
Dim Mycmd as Control
Private Sub CommandButton1_Click()
Set Mycmd = Controls.Add("MSForms.CommandButton.1") ',
CommandButton2, Visible)
Mycmd.Left = 18
Mycmd.Top = 150
Mycmd.Width = 175
Mycmd.Height = 20
Mycmd.Caption = "This is fun." & Mycmd.Name
End Sub
Private Sub UserForm_AddControl(ByVal Control As _
MSForms.Control)
Label1.Caption = "Control was Added."
End Sub