Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I transform a word response to a numeric response? kanegaro Excel Discussion (Misc queries) 0 January 11th 08 05:08 PM
How do I set up a daily call out response response register? Pule Excel Worksheet Functions 1 October 7th 07 01:34 PM
Why does the click event get control? Lee Hunter Excel Programming 1 October 31st 05 06:26 PM
Addition to Worksheet Change event (RP?) Steph[_3_] Excel Programming 1 April 19th 05 05:38 PM
Control Exit event Fred Excel Programming 0 November 19th 03 12:59 AM


All times are GMT +1. The time now is 12:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"