educate889
Technical User
I need help!
I have a series of queries that are used at month end and need to automate the process of dumping data into Excel.
I can get them to export to Excel, but I need each query in it's own worksheet within the main workbook.
Here is the code I am presently using, it is in public function just for trials on my part. This works but then overwrites the first query ... I think I am just missing a line of code (or 2) that creates and names the worksheet tabs in excel.
Public Function Create_Export()
On Error GoTo Create_Export_Err
DoCmd.SetWarnings False
DoCmd.OpenQuery "XCM101_ICTOTALS", acViewNormal, acEdit
DoCmd.Close acQuery, "XCM101_ICTOTALS", acSavePrompt
DoCmd.OpenQuery "XCM102_SLSTOTALS", acViewNormal, acEdit
DoCmd.SetWarnings True
DoCmd.OutputTo acQuery, "", "MicrosoftExcel(*.xls)", "H:\XCM_RawData.xls", True, ""
Create_Export_Exit:
Exit Function
Create_Export_Err:
MsgBox Error$
Resume Create_Export_Exit
End Function
Any help would be greatly appreciated.
I have a series of queries that are used at month end and need to automate the process of dumping data into Excel.
I can get them to export to Excel, but I need each query in it's own worksheet within the main workbook.
Here is the code I am presently using, it is in public function just for trials on my part. This works but then overwrites the first query ... I think I am just missing a line of code (or 2) that creates and names the worksheet tabs in excel.
Public Function Create_Export()
On Error GoTo Create_Export_Err
DoCmd.SetWarnings False
DoCmd.OpenQuery "XCM101_ICTOTALS", acViewNormal, acEdit
DoCmd.Close acQuery, "XCM101_ICTOTALS", acSavePrompt
DoCmd.OpenQuery "XCM102_SLSTOTALS", acViewNormal, acEdit
DoCmd.SetWarnings True
DoCmd.OutputTo acQuery, "", "MicrosoftExcel(*.xls)", "H:\XCM_RawData.xls", True, ""
Create_Export_Exit:
Exit Function
Create_Export_Err:
MsgBox Error$
Resume Create_Export_Exit
End Function
Any help would be greatly appreciated.