View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ken Soenen Ken Soenen is offline
external usenet poster
 
Posts: 25
Default Dynamic Control addition and Event response

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