Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Identifying a Control Type
How do I identify what type of control I have on a form
Dim c As Control For Each c In UserForm1.Controls if c (is a text box) then some code Next c What goes in the brackets? Chrissy. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Identifying a Control Type
Hi,
If TypeOf c Is Listbox then .... Heiko :-) "Chrissy" wrote: How do I identify what type of control I have on a form Dim c As Control For Each c In UserForm1.Controls if c (is a text box) then some code Next c What goes in the brackets? Chrissy. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Identifying a Control Type
You also need to qualify the object type name with the MSForms type library or your code will be looking for different set of controls with the same name in the Excel type library, e.g.: If TypeOf c Is MSForms.ListBox then If TypeOf c Is MSForms.TextBox then etc.... -- Rob Bovey, MCSE, MCSD, Excel MVP Application Professionals http://www.appspro.com/ * Please post all replies to this newsgroup * * I delete all unsolicited e-mail responses * "Heiko" wrote in message ... Hi, If TypeOf c Is Listbox then ... Heiko :-) "Chrissy" wrote: How do I identify what type of control I have on a form Dim c As Control For Each c In UserForm1.Controls if c (is a text box) then some code Next c What goes in the brackets? Chrissy. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Identifying a Control Type
I was not aware of the operator(?) TypeOf. Even though VBA
does consider it legal, I cannot find any help on it, and, what's more, it did not work in an example I had a look at (identifying a check box control on a form). It may depend on the sofware versions, I don't know. The following did work: Dim c As Control For Each c In UserForm1.Controls if TypeName(c)="TextBox" then some code Next c |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Identifying a Control Type
Hi Arne,
This section from the help topic on the If...Then...Else statement describes the TypeOf operator: An expression of the form TypeOf objectname Is objecttype. The objectname is any object reference and objecttype is any valid object type. The expression is True if objectname is of the object type specified by objecttype; otherwise it is False. -- Rob Bovey, MCSE, MCSD, Excel MVP Application Professionals http://www.appspro.com/ * Please post all replies to this newsgroup * * I delete all unsolicited e-mail responses * "Arne" wrote in message ... I was not aware of the operator(?) TypeOf. Even though VBA does consider it legal, I cannot find any help on it, and, what's more, it did not work in an example I had a look at (identifying a check box control on a form). It may depend on the sofware versions, I don't know. The following did work: Dim c As Control For Each c In UserForm1.Controls if TypeName(c)="TextBox" then some code Next c |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Identifying a Control Type
Aha, I see. Thanks for informing me.
Arne |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Process control chart for quality control in exel? | Charts and Charting in Excel | |||
2007 Form Control/ActiveX Control font difference | Excel Discussion (Misc queries) | |||
Excel spin box - no Control tab in Format Control dialong box | Excel Worksheet Functions | |||
Nested If statement to control format of number-type cells | Excel Worksheet Functions | |||
Difference between a Forms Control verus Active-X Control | Excel Discussion (Misc queries) |