+ Reply to Thread
Results 1 to 2 of 2

Connecting To a Excel Database

  1. #1
    NOODLES101487
    Guest

    Connecting To a Excel Database


    Hi All, Im pretty new to vba programming Ive developed simple vb apps in
    the past but never needed to connect to a database.

    What do I need to do setup the connection, Ive currently got this in my
    code and throws up an error message:

    Dim cn as ADODB.Connection
    Set cn = New ADODB.Connection
    With cn
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .ConnectionString = "Data Source=C:\MyFolder\MyWorkbook.xls;" & _
    "Extended Properties=Excel 8.0;"
    .Open
    End With

    When I try to run it I get the error: User defined type not defined
    for the ADODB.Connection so I havnt set this up correctly I have MDAC
    2.5 already installed so what else do I need to setup.

    Thanks in Advance.


    --
    NOODLES101487
    ------------------------------------------------------------------------
    NOODLES101487's Profile: http://www.hightechtalks.com/m84
    View this thread: http://www.hightechtalks.com/t2261106


  2. #2
    David Lloyd
    Guest

    Re: Connecting To a Excel Database

    Your error message is likely cause because you do not have a reference set
    up for the Microsoft ActiveX Data Object (ADO) library in your project. In
    the Visual Basic Editor, select References from the Tools menu and add a
    reference for this library.

    --
    David Lloyd
    MCSD .NET
    http://LemingtonConsulting.com

    This response is supplied "as is" without any representations or warranties.


    "NOODLES101487" <[email protected]> wrote
    in message news:[email protected]...

    Hi All, Im pretty new to vba programming Ive developed simple vb apps in
    the past but never needed to connect to a database.

    What do I need to do setup the connection, Ive currently got this in my
    code and throws up an error message:

    Dim cn as ADODB.Connection
    Set cn = New ADODB.Connection
    With cn
    ..Provider = "Microsoft.Jet.OLEDB.4.0"
    ..ConnectionString = "Data Source=C:\MyFolder\MyWorkbook.xls;" & _
    "Extended Properties=Excel 8.0;"
    ..Open
    End With

    When I try to run it I get the error: User defined type not defined
    for the ADODB.Connection so I havnt set this up correctly I have MDAC
    2.5 already installed so what else do I need to setup.

    Thanks in Advance.


    --
    NOODLES101487
    ------------------------------------------------------------------------
    NOODLES101487's Profile: http://www.hightechtalks.com/m84
    View this thread: http://www.hightechtalks.com/t2261106



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1