Results 1 to 5 of 5

Thread: sql in vba - could not find a file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    sql in vba - could not find a file

    Hi
    I am tryign to get this work, yet i simply cannot find why this macro does not find a file

    the error message is as follows: ms database engine could not find the object sheet1 - it is a runtime error


    the files which i want to export values to, exist for sure - i created them myself

    Could you please help me with this?



    Sub output_into_files()
    
    
    Dim CONNECT As New ADODB.Connection
    Dim query1 As New ADODB.Recordset
    Dim path As String
    Dim name As String
    Dim a As Integer
    Dim sheetValue As String
    Dim QueryString As String
    
    
    
    
    path = "C:\RS_DESKTOP\vba\VBA COURSE - 8-9.12.14\DANE\for external output\"
    
    
    name = Dir(path)
    
    
    a = 1
    sheetValue = "sheet" & a
    
    
    Do Until name = ""
    
    
        CONNECT.Open "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" & path & name & ";"
        
        QueryString = "INSERT INTO sheet" & a & " VALUES ('test')"
        
    Call query1.Open(QueryString, CONNECT)
    CONNECT.Close
            
        name = Dir
        a = a + 1
    Loop
    
    
    End Sub
    Last edited by SamT; 12-18-2014 at 04:23 AM. Reason: Added Code tags with the # Icon

Tags for this Thread

Posting Permissions

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