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.TransferS preadsheet acExport, 8, "Table1", "D:\Test.xl s", True
Dim xlObj
Set xlObj = CreateObject("e xcel.applicatio n")
xlObj.Workbooks .Open "D:\Template.xl s"
xlObj.activewor kbook.saveas "D:\Date.xl s"
xlObj.Workbooks .Open "D:\Test.xl s"
xlObj.activeshe et.cells.select
xlObj.activeshe et.cells.Copy
xlObj.Workbooks ("Date.xls").Ac tivate
xlObj.activewor kbook.sheets(1) .range("a1").se lect
xlObj.activeshe et.paste
xlObj.activeshe et.Visible = False
xlObj.activewor kbook.Save
xlObj.activewor kbook.Close
xlObj.activewor kbook.Save
xlObj.activewor kbook.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.activewor kbook.sheets(2) .range("a1").se lect, 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