Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dynamic Control addition and Event response
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dynamic Control addition and Event response
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dynamic Control addition and Event response
A little search of Google will show you lots of samples.
http://groups.google.co.uk/group/mic...65b0e85e2c7312 or http://snipurl.com/ltxq Ken Soenen wrote: 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 -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dynamic Control addition and Event response
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dynamic Control addition and Event response
Thanks for your help Dave.
ken "Dave Peterson" wrote in message ... A little search of Google will show you lots of samples. http://groups.google.co.uk/group/mic...65b0e85e2c7312 or http://snipurl.com/ltxq Ken Soenen wrote: 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 -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Dynamic Control addition and Event response
Thanks Tom.
ken "Tom Ogilvy" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I transform a word response to a numeric response? | Excel Discussion (Misc queries) | |||
How do I set up a daily call out response response register? | Excel Worksheet Functions | |||
Why does the click event get control? | Excel Programming | |||
Addition to Worksheet Change event (RP?) | Excel Programming | |||
Control Exit event | Excel Programming |