Subject: Insert Excel sheet content into Access table from
Posted By: stepdev Post Date: 12/7/2006 1:22:46 PM
The subject just about explains my goal.  From an access form,  a button launches the following...

firstpath = "C:\class\orders.xls"
        
        Dim XL As Excel.Application
        Dim XLBook As Excel.Workbook
        Dim XLSheet As Excel.Worksheet

Set XL = CreateObject("Excel.Application")
    Set XLBook = GetObject(firstpathj)
      
    Set XLSheet = XLBook.Worksheets(1)     


   DoCMD.RunSQL "INSERT INTO TABLE1 (VAR1, VAR1, ....)" & _
   "SELECT XLSheet.Cells(1,1), XLSheet.Cells(1,2) from XLSheet"


   I get the error
"MS Jet database engine could not find the input table or query XLSheet."   

Does anyone know how to identify to access that xlsheet is the data source?    


Thanks.               
               
                


Reply By: mmcdonal Reply Date: 12/8/2006 2:39:41 PM
I loaned out my book called "Integrating Excel and Access" published by O'Reilly, otherwise I would try to answer this. Look up the book if you are doing this sort of thing on a regular basis.

mmcdonal
Reply By: echovue Reply Date: 12/8/2006 3:18:27 PM
There is a transferSpreadsheet function that might be useful here.  I don't recall the exact syntax but it's a one line solution.

Hope that helps,

Mike

Mike
EchoVue.com

Go to topic 53388

Return to index page 98
Return to index page 97
Return to index page 96
Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89