I have VBA codes in Access 2000 that would declare an object and set it to an Excel workbook as follows. It would crash if the excel spreadsheet is already opened manually in Excel.
How could I detect whether such worksheet is opened and if so, CLOSE it??
How could I detect whether such worksheet is opened and if so, CLOSE it??
Code:
dim xlBk as Excel.Workbook
Set xlBk = Workbooks.Open(file)
Set xlSheet = xlBk.Worksheets(1)