J
judith
I am trying to download some data from access into Excel and then copy it
into an existing excel file
' Create a new instance of Excel
Set xlApp = New Excel.Application
' Make it visible
xlApp.Visible = True
' Open the file
Set xlWorkBook1 = xlApp.Workbooks.Open(strInputFileName)
' save down data
DoCmd.OpenQuery "rptQry003ReconBaseTable"
' download Access Query to excel
strInputFilePath = xlWorkBook1.Path
DoCmd.TransferSpreadsheet acExport, 8, "tbl99ReconRepBase",
strInputFilePath & "\sheet15temp.xls"
' Open the file
Set xlWorkBook2 = xlApp.Workbooks.Open(strInputFilePath &
"\sheet15temp.xls")
' copy in data
xlWorkBook1.Activate
.....
This seems to work fine except if Excel is already open. In which case it
gives an error on the last line
Run time error 1004
Method 'Sheets' of object Global failure
any suggestions please
into an existing excel file
' Create a new instance of Excel
Set xlApp = New Excel.Application
' Make it visible
xlApp.Visible = True
' Open the file
Set xlWorkBook1 = xlApp.Workbooks.Open(strInputFileName)
' save down data
DoCmd.OpenQuery "rptQry003ReconBaseTable"
' download Access Query to excel
strInputFilePath = xlWorkBook1.Path
DoCmd.TransferSpreadsheet acExport, 8, "tbl99ReconRepBase",
strInputFilePath & "\sheet15temp.xls"
' Open the file
Set xlWorkBook2 = xlApp.Workbooks.Open(strInputFilePath &
"\sheet15temp.xls")
' copy in data
xlWorkBook1.Activate
.....
This seems to work fine except if Excel is already open. In which case it
gives an error on the last line
Run time error 1004
Method 'Sheets' of object Global failure
any suggestions please