I have an excel VBA application where I disable the X button at application launch, when quitting the application the last sheet remains open and I can't close it! The code I use is;
Public DisableX As Boolean
Sub Workbook_BeforeClose(Cancel As Boolean)
'Close workbook from main form only!
If DisableX = False Then Cancel = True
Any thoughts will be appreciated.