ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Events with diniamically added controls (https://www.excelbanter.com/excel-programming/373288-events-diniamically-added-controls.html)

Fernando

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


Tom Ogilvy

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




Fernando

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





Fernando

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





Fernando

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






All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com