MSForms.ComboBox

  • Thread starter Thread starter John Pierce
  • Start date Start date
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?
 
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 *
 
(e-mail address removed) (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.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top