I need help with exporting data from 2 access tables, into 2 existing
spreadsheets in a single Excel file.
Currently, I am using this code:
DoCmd.TransferSpreadsheet acExport, 8, "Table1", "D:\Test.xls", True
Dim xlObj
Set xlObj = CreateObject("excel.application")
xlObj.Workbooks.Open "D:\Template.xls"
xlObj.activeworkbook.saveas "D:\Date.xls"
xlObj.Workbooks.Open "D:\Test.xls"
xlObj.activesheet.cells.select
xlObj.activesheet.cells.Copy
xlObj.Workbooks("Date.xls").Activate
xlObj.activeworkbook.sheets(1).range("a1").select
xlObj.activesheet.paste
xlObj.activesheet.Visible = False
xlObj.activeworkbook.Save
xlObj.activeworkbook.Close
xlObj.activeworkbook.Save
xlObj.activeworkbook.Close
xlObj.Quit
Set xlObj = Nothing
MsgBox "Report exported successfully"
Dim stAppName As String
stAppName = "Excel.exe D:\date.xls"
Call Shell(stAppName, 1)
End Sub
This works fine, but just with one table. When I try to export another
table with the same code to
xlObj.activeworkbook.sheets(2).range("a1").select, then I get an error
about subcscipt out of range...
I am wondering if I should create a temp.xls file on the second table
instead, and have an access macro do the copying between the 2
workbooks. I am still unable to get this for the past 3 days.
Please help !
Cheers!
Sunny