PDA

View Full Version : Solved: Closing Excel by clicking the Red X



anthony20069
10-06-2009, 07:37 AM
Hi guys.

I have a button that does some validation on a workbook, then closes Excel. What i would like; is that if the users clicks on the "Red Cross" (top right) in excel, that the same validation is run before closing excel - is this possible?

thanks

***************************
EDIT: Ok figured it out,

Put this code in the "Thisworkbook"





Private Sub Workbook_BeforeClose(Cancel As Boolean)
If [your criteria] then
MsgBox "can't close now !!"
Cancel = True
endif
End Sub