using Jet with text (csv) file
Am I doing something wrong or are file names that include a period illegal? I have two identical csv files (PhoneList.csv and Phone.List.csv) but the latter one can't be opened using ADO and Jet.
Code:
Sub ADO_Fail()
Dim objConn As Object
Dim objRs As Object
Dim strPathtoTextFile As String
Set objConn = CreateObject("ADODB.Connection")
Set objRs = CreateObject("ADODB.Recordset")
strPathtoTextFile = "C:\"
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended Properties=""text;HDR=YES;FMT=Delimited"""
'works ok
objRs.Open "SELECT * FROM PhoneList.csv", objConn, 3, 3, 1
objRs.Close
'fails ==> The Microsoft Jet database Engine could not find the object Phone.List.csv...
objRs.Open "SELECT * FROM Phone.List.csv", objConn, 3, 3, 1
objRs.Close
objConn.Close
Set objRs = Nothing
Set objConn = Nothing
End Sub
Re: using Jet with text (csv) file
I'm not sure, but that might be an issue.
What is much more likely to be the issue is the location of the file... you should not store files in the root of a drive (mainly because there are various permission based issues involved), and instead should create them inside a folder.
Re: using Jet with text (csv) file
Location isn't the issue. I originally had the files in a folder. I only put them in the root for simplicity for the post.
Re: using Jet with text (csv) file
Would someone be willing to try the code in the first post to see if they get the same result (i.e. filename with a period doesn't work)? I'm surprised there would be such a limitation.