philfer
12-31-2007, 12:53 PM
I am using the following to export query results from Access to Excel
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Hello", "C:\data\phil.xls"
However it says it cant find the objext phil.xls
When I replace this with a new book i.e. Book4.xls which is closed it works OK and creates a new sheet with the same name as the query and drops in the data.
When I put the code in Book4 and point it at phil.xls as long as phil.xls is closed it works.
Why is this happening.
Also rather than having it create a new sheet is there any way I can make it paste the data into an existing sheet in phil.xls each time I run the code
Any help would be appreciated
Thanks
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Hello", "C:\data\phil.xls"
However it says it cant find the objext phil.xls
When I replace this with a new book i.e. Book4.xls which is closed it works OK and creates a new sheet with the same name as the query and drops in the data.
When I put the code in Book4 and point it at phil.xls as long as phil.xls is closed it works.
Why is this happening.
Also rather than having it create a new sheet is there any way I can make it paste the data into an existing sheet in phil.xls each time I run the code
Any help would be appreciated
Thanks