Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Events with diniamically added controls

Hi,

I have an application in VBA were I dinamically add several controls to a
form. Im creating arrays of variables of type Control to access the added
controls, for ex:

Set ctrl_graph(i) = page_id.Controls.Add(add_chkbox_string, "ctrl_graph" & i)

Now I need to add events to this controls, but I have encountered that
'WithEvents' doesnt work with arrays. How can I add events to this controls?

Greetings
Fernando

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Events with diniamically added controls

Take a look here - I think the technique used there will apply.

http://www.j-walk.com/ss/excel/tips/tip44.htm
John Walkenbach's site.

--
Regards,
Tom Ogilvy

"fernando" wrote in message
...
Hi,

I have an application in VBA were I dinamically add several controls to a
form. Im creating arrays of variables of type Control to access the added
controls, for ex:

Set ctrl_graph(i) = page_id.Controls.Add(add_chkbox_string, "ctrl_graph" &
i)

Now I need to add events to this controls, but I have encountered that
'WithEvents' doesnt work with arrays. How can I add events to this
controls?

Greetings
Fernando



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Events with diniamically added controls

Tom,

This code works fine, but only with comboboxes, im using also textboxes and
checkboxes, if I define in the class module this:

Public WithEvents ctrl As CheckBox

I get "the object doesnt have automation events", hope the translation is ok.

fernando

"Tom Ogilvy" wrote:

Take a look here - I think the technique used there will apply.

http://www.j-walk.com/ss/excel/tips/tip44.htm
John Walkenbach's site.

--
Regards,
Tom Ogilvy

"fernando" wrote in message
...
Hi,

I have an application in VBA were I dinamically add several controls to a
form. Im creating arrays of variables of type Control to access the added
controls, for ex:

Set ctrl_graph(i) = page_id.Controls.Add(add_chkbox_string, "ctrl_graph" &
i)

Now I need to add events to this controls, but I have encountered that
'WithEvents' doesnt work with arrays. How can I add events to this
controls?

Greetings
Fernando




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Events with diniamically added controls

can the controls events, props and methods be 'inherited'?, for ex. top,
caption, setfocus, etc.

"Tom Ogilvy" wrote:

Take a look here - I think the technique used there will apply.

http://www.j-walk.com/ss/excel/tips/tip44.htm
John Walkenbach's site.

--
Regards,
Tom Ogilvy

"fernando" wrote in message
...
Hi,

I have an application in VBA were I dinamically add several controls to a
form. Im creating arrays of variables of type Control to access the added
controls, for ex:

Set ctrl_graph(i) = page_id.Controls.Add(add_chkbox_string, "ctrl_graph" &
i)

Now I need to add events to this controls, but I have encountered that
'WithEvents' doesnt work with arrays. How can I add events to this
controls?

Greetings
Fernando




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Events with diniamically added controls

Finally got it!

"Tom Ogilvy" wrote:

Take a look here - I think the technique used there will apply.

http://www.j-walk.com/ss/excel/tips/tip44.htm
John Walkenbach's site.

--
Regards,
Tom Ogilvy

"fernando" wrote in message
...
Hi,

I have an application in VBA were I dinamically add several controls to a
form. Im creating arrays of variables of type Control to access the added
controls, for ex:

Set ctrl_graph(i) = page_id.Controls.Add(add_chkbox_string, "ctrl_graph" &
i)

Now I need to add events to this controls, but I have encountered that
'WithEvents' doesnt work with arrays. How can I add events to this
controls?

Greetings
Fernando




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
Click events not working when added during runtime crazybass2 Excel Programming 3 July 10th 06 04:06 PM
Manipulate Controls added at runtime [email protected] Excel Programming 5 January 17th 06 09:50 AM
add event to controls added in runtime Brotha lee Excel Programming 1 May 21st 05 10:32 AM
Event procedures for controls added with Controls.Add John Austin[_4_] Excel Programming 1 March 9th 05 03:31 PM
how to access programatically added controls don bowyer Excel Programming 3 August 8th 04 11:28 AM


All times are GMT +1. The time now is 12:29 AM.

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"