Results 1 to 4 of 4

Thread: using Jet with text (csv) file

  1. #1

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    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

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  3. #3

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    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.

  4. #4

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    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.

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