Not sure why you are adding a control with code - I would bet there is a
simpler way to accomplish what you need. Nonetheless, you might look at
John Walkenbach's sample:
http://www.j-walk.com/ss/excel/tips/tip76.htm
--
Regards,
Tom Ogilvy
"Ken Soenen" wrote in message
...
Thanks Dave. I tried Chip's "code creation stuff" but the problem still
is
selecting the "NAME" XXXX that would be placed in front of the "_Click()"
in the event handler declaration. Like: Private Sub XXXX_Click().
ken
"Dave Peterson" wrote in message
...
Chip Pearson has some instructions on writing code that writes code at:
http://cpearson.com/excel/vbe.htm
Ken Soenen wrote:
I dynamically added a CommandButton using the ADD method as shown
below.
Now
the problem is: How do I define?,create?,handle? the click event that
is
generated by that control. I have tried putting in event handlers
named:
Private Sub CommandButton1_Click()
Private Sub Zbut_Click()
Private Sub ZButton_Click()
and none work.
Thanks,
ken
Dim ZButton As Control
Set ZButton = Controls.Add("Forms.CommandButton.1", "ZBut")
With ZButton
.left = 17
.top = 30
.Width = 12
.Height = 12
.BackColor = &H8000000F
.ForeColor = &H80000012
.Caption = "Z"
.FontSize = 10
.Font.Bold = True
End With
--
Dave Peterson