We help IT Professionals succeed at work.

Excel 2003 Connection error message "User-defined type not defined"

Medium Priority
Last Modified: 2012-05-06
From Excel 2003 need to connect to Access database.  
This line of VB code in the Visual Basic Editor    
Dim cnn As ADODB.Connection  
always gives error message : "User-defined type not defined"

Dim cnn As ADODB.Connection
Set cnn = New adodb.Connection
   With cnn
      .ConnectionTimeout = 500
      .Provider = "Microsoft.Jet.OLEDB.4.0"
      .ConnectionString = "Data Source=" & strPathToDB & ";"
      .CommandTimeout = 500
   End With

Open in new window

Watch Question

This means that you have not referened the ADODB library.

In your VBA editor. goto tools->references and add reference to Microsoft ActiveX Data Objects library


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Thank you.  I just found the answer myself.  You are fast!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.