I am having an unusual issue. I have two workbooks open and simply want to close both without saving either of them. One workbook is a UI and the other a database that the user never sees. If I click the 'x' in the top right, it works fine but if I try to close via VBA code, the database workbook does not close.
From the UI workbook I have:
I also have a Workbook_BeforeClose method that is as follows:
No error message or anything. The workbook just doesn't close when I try to close it via VBA code. Any ideas?
From the UI workbook I have:
Code:
Private Sub Run_Shell_Command()
currentDir = ActiveWorkbook.Path 'Directory of current workbook
batchPath = currentDir & "\update.bat" 'Full path to batch file
'Run batch file with argument of current directory
Shell batchPath & " " & currentDir, vbNormalFocus
'Close workbook so that batch file can overwrite files
ActiveWorkbook.Close
End Sub
I also have a Workbook_BeforeClose method that is as follows:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbooks("DB.xls").Saved = True
Workbooks("DB.xls").Close
ThisWorkbook.Saved = True
End Sub
No error message or anything. The workbook just doesn't close when I try to close it via VBA code. Any ideas?