Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4076076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:22:45+00:00 2026-05-20T17:22:45+00:00

I get the compile-time error User-defined types not defined on this line: Dim cn

  • 0

I get the compile-time error “User-defined types not defined” on this line:

Dim cn As ADODB.Connection

What could be wrong?

Code:

Sub test()

    Dim cn As ADODB.Connection

    'Not the best way to get the name, just convenient for notes

    strFile = Workbooks(1).FullName
    strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFile & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"
    Set cn = CreateObject("ADODB.Connection")
    'For this to work, you must create a DSN and use the name in place of

    'DSNName

    'strSQL = "INSERT INTO [ODBC;DSN=DSNName;].NameOfMySQLTable " & "Select AnyField As NameOfMySQLField FROM [Sheet1$];"
     strSQL = "SELECT F1 FROM [Sheet1$];"
     cn.Execute strSQL
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:22:46+00:00Added an answer on May 20, 2026 at 5:22 pm

    I had forgotten to add a reference to “Microsoft ActiveX Data Objects 2.5 Library”: This reference is required for early binding.

    How to get to that reference:

    Tools > References > Check the checkbox in front of “Microsoft ActiveX Data Objects 2.5 Library”

    Other libraries that work include:

    Microsoft ActiveX Data Objects 2.6 Library

    Microsoft ActiveX Data Objects 2.7 Library

    Microsoft ActiveX Data Objects 2.8 Library

    Microsoft ActiveX Data Objects 6.1 Library

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get an error when I compile this code: using System; public struct Vector2
Are all Enum enumerations constants? Do they get converted to their value at compile-time
When trying to compile my class I get an error: The constant 'NamespaceName.ClassName.CONST_NAME' cannot
I get the following error when I try to compile an asp.net site using
When attempting to compile my C# project, I get the following error: 'C:\Documents and
Why don't we get compile errors on inline code errors in asp.net mvc views
EDIT: I found out that I can get it to compile if I cast
I get the following message in a VC6 project compile: OTE: WINVER has been
When I compile my application under Delphi 2006 I get the following warning [Pascal
def foo (): x = re.compile('^abc') foo2(x) def foo2(x): How do I get x

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.