MSForms.ComboBox

J

John Pierce

I have the following line in some borrowed code:
Dim Ctl As MSForms.ComboBox
I get Error: "User-defined type not defined" when I run it.
Do I need to create a Reference to an object library, or
define a new class in a class module, or what?
 
R

Rob Bovey

John Pierce said:
I have the following line in some borrowed code:
Dim Ctl As MSForms.ComboBox
I get Error: "User-defined type not defined" when I run it.
Do I need to create a Reference to an object library, or
define a new class in a class module, or what?

Hi John,

The MSForms.ComboBox control is part of the Microsoft Forms 2.0 Object
Library, so you would need to have a reference set to this. This reference
is added automatically when you add a UserForm to your project or put a
control from the Control Toolbox onto a worksheet.

--
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 *
 
J

Jamie Collins

[email protected] (John Pierce) wrote ...
I have the following line in some borrowed code:
Dim Ctl As MSForms.ComboBox
I get Error: "User-defined type not defined" when I run it.
Do I need to create a Reference to an object library, or
define a new class in a class module, or what?

Easiest thing would be to add either a userform to your vba project or
add a control from the Control Toolbox toolbar to a worksheet e.g. a
ComboBox <g>. It's likely your code was taken from a class module e.g.
a worksheet's code module or useform code module.

Jamie.

--
 
J

John Pierce

Thanks for the suggestions, Rob, Jamie. As I suspected, and as Rob
confirmed, creating the reference to the Forms libray did it.
 
Top