I am using the DoCmd.TransferSpreadsheet to transfer a query to an excel spreadsheet and then Open the Spreadsheet.
Works great - but only if the spreadsheet is Closed. If it's still opened, then I get an error that the table is already opened. Is there a way to check if the spreadsheet is open. Basically, I need to:
1) check if the spreadsheet is open
2) If it's opened, then close it
3) run the DoCmd.TransferSpreadsheet
4) Open the spreadsheet.
Thanks
Code:
Dim oApp As Object
Set oApp = CreateObject("Excel.Application")
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel19, "qryActionItems", CurrentProject.Path & "\" & "Action Items.xls", True
oApp.Workbooks.Open Application.CurrentProject.Path & "\Action Items.xls", True, False
oApp.Visible = True
oApp.UserControl = True
Works great - but only if the spreadsheet is Closed. If it's still opened, then I get an error that the table is already opened. Is there a way to check if the spreadsheet is open. Basically, I need to:
1) check if the spreadsheet is open
2) If it's opened, then close it
3) run the DoCmd.TransferSpreadsheet
4) Open the spreadsheet.
Thanks