Results 1 to 3 of 3

Thread: [RESOLVED] Problem reading excel file using ADO!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Posts
    25

    Resolved [RESOLVED] Problem reading excel file using ADO!

    Hi,

    I tried to read a excel file using the method i found here http://www.xtremevbtalk.com/showthread.php?t=217783

    But i get an error on ADODB.Connection saying "Type 'ADODB.Connection' is not defined" in the following code:

    Code:
    Private Function GetExcelConnection(ByVal Path As String, _
        Optional ByVal Headers As Boolean = True) As Connection
        Dim strConn As String
        Dim objConn As ADODB.Connection
        Set objConn = New ADODB.Connection
        strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                  "Data Source=" & Path & ";" & _
                  "Extended Properties=""Excel 8.0;HDR=" & _
                  IIf(Headers, "Yes", "No") & """"
        objConn.Open strConn
        Set GetExcelConnection = objConn
    End Function
    It was used in VB6... do i need to do something special in Visual Studio 2010? What is wrong in this code?

    thanks

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Posts
    25

    Re: Problem reading excel file using ADO!

    Anyone know what to do? Seems to be a simple declaration or define ADODB object in my project but i dont know how to do it in Visual Studio 2010! I have not used VB since VB6... im a bit lost lol.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Posts
    25

    Re: Problem reading excel file using ADO!

    Never mind i found it. It was simply Project->Add Reference. Then choose "Microsoft ActiveX Data Objects 2.8 Library" (latest one)

Posting Permissions

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



Click Here to Expand Forum to Full Width