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

Posted on 2009-02-17
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

Question by:OceanStars
LVL 22

Accepted Solution

spattewar earned 200 total points
ID: 23662452
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


Author Closing Comment

ID: 31547915
Thank you.  I just found the answer myself.  You are fast!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Gain an elementary understanding of Blockchain technology.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question