Hi All,
I have a command button which runs some code to export a query into excel and then open a few bits (not important for this).
If this is run again the code errors as the excel file is already open so the new one cant be opened with the new data. Is there a simple way to close the open excel file before the new one is open? I am presuming i need some sort of close command before the "DoCmd.OutputTo"?
Code behind the button below:
Thank you.
I have a command button which runs some code to export a query into excel and then open a few bits (not important for this).
If this is run again the code errors as the excel file is already open so the new one cant be opened with the new data. Is there a simple way to close the open excel file before the new one is open? I am presuming i need some sort of close command before the "DoCmd.OutputTo"?
Code behind the button below:
Code:
Private Sub Command40_Click()
DoCmd.OutputTo acOutputQuery, "TOA_Report_History", acFormatXLS, "C:\Users\jxl\Documents\querysave.xls", 1
DoCmd.OpenQuery "TOA_Report_History_Transpose_Delete"
DoCmd.OpenTable "TOA_Report_History_Transpose"
End Sub
Thank you.