Hi All
I currently use the DoCmd.TransferSpreadsheet sample code below to export multiple queries to a single Excel workbook on a weekly basis.
It works well in that each query is output to a individual tabs in the one workbook.
However, what I'd ultimately like to do, instead of creating a new file each time I export, is to have the data from each of the queries automatically append to the respective worksheets (query1, query2, query3).
I would like the data to be placed after the last row of data on each worksheet and the workbook to automatically save and close without being prompted.
I have searched extensively but can't seem to find anything that I have the skills to be able to modify that will do this.
Would someone please be able to help me with this?
Many thanks
darls15
~~~~~~~~~~~~~~~~~~~
Sub ExportQueryData()
Dim strFilePath As String
strFilePath = "C:\Output"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "exp_query1", strFilePath + "alldata.xlsx", True, "query1"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "exp_query2", strFilePath + "alldata.xlsx", True, "query2"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "exp_query3", strFilePath + "alldata.xlsx", True, "query3"
End Sub