Forum

Close 'X' before sa...
 
Notifications
Clear all

Close 'X' before save workbook prevention

2 Posts
2 Users
0 Reactions
86 Views
(@stevenbehr1)
Posts: 92
Estimable Member
Topic starter
 

Hi,

 

I have created a Save and Close Macro (Below), So that the command button been assigned for the user to use before exiting

    ActiveWorkbook.Close SaveChanges:=True

 

What Im trying to prevent is the Close "X" button to be pressed and for user to stop save as and to use a MSG "Please use the save and Close button". is there a code that when you press "X" close button that you cant close unless you hit Save and close command button.

 

Thanks

 

Steve

 
Posted : 25/02/2020 6:48 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Steve,

In the ThisWorkbook module use this event:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Cancel = True
' YOUR CODE GOES HERE

End Sub

Regards

Phil

 
Posted : 26/02/2020 3:06 am
Share: