ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   changing an activex control property using a macro (https://www.excelbanter.com/excel-discussion-misc-queries/172606-changing-activex-control-property-using-macro.html)

Sian

changing an activex control property using a macro
 
Here's the thing: I have one large procedure (BigCode) which I call from
many different small procedures:
call BigCode (mycontrol, 1)

'mycontrol' is the name of an activex control.

One of the things I want Bigcode to do is change properties of mycontrol,
for example

With mycontrol
.Locked = True
End with

My question is what do I pass as mycontrol? Or how to I get BigCode to
understand it's the control itself I want to change (at the moment every
variable translates to eg "Combobox1" (in quotes)

Help greatly appreciated!
Sian

Dave Peterson

changing an activex control property using a macro
 
You could pass it as a generic object:
Sub BigCode(myControl as Object)

If you were only passing comboboxes from the control toolbox toolbar (placed on
a worksheet), you could pass it as a combobox:
sub bigcode(myCombobox as msforms.combobox)

This would work if your combobox was on a userform, too.




Sian wrote:

Here's the thing: I have one large procedure (BigCode) which I call from
many different small procedures:
call BigCode (mycontrol, 1)

'mycontrol' is the name of an activex control.

One of the things I want Bigcode to do is change properties of mycontrol,
for example

With mycontrol
.Locked = True
End with

My question is what do I pass as mycontrol? Or how to I get BigCode to
understand it's the control itself I want to change (at the moment every
variable translates to eg "Combobox1" (in quotes)

Help greatly appreciated!
Sian


--

Dave Peterson


All times are GMT +1. The time now is 02:15 AM.

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