Hi
I am having problems reading an Excel file using OleDb.OleDbConnection. Using this code
I get the error "External table is not in the expected format" at
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
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()
Thanks in advance