Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External table is not in the expected format

Status
Not open for further replies.

Scrollon

IS-IT--Management
Mar 19, 2007
2
GB
Hi
I am having problems reading an Excel file using OleDb.OleDbConnection. Using this code

Code:
   Private Function GetExcelConnection(ByVal Path As String, _
    Optional ByVal Headers As Boolean = True) As OleDb.OleDbConnection
        Dim strConn As String
        Dim objConn As OleDb.OleDbConnection

        strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                 "Data Source=" & Path & ";" & _
                "Extended Properties=""Excel 8.0;IMEX=1;HDR=" & _
               IIf(Headers, "Yes", "No") & """"

        objConn = New OleDb.OleDbConnection(strConn)
        objConn.Open()
        GetExcelConnection = objConn
    End Function

I get the error "External table is not in the expected format" at
Code:
       objConn.Open()
I do NOT get the error if I have my Excel file open at the time, everything works just fine and I can read my data. Does the Excel file have to be open for this type of connection to work?

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top