Skip the "save your changes?" message when closing file

Bagharmin

Board Regular
Joined
Nov 22, 2010
Messages
168
I searched for this, but apparently not correctly as I couldn't find anything that addressed it.

When a user closes the workbook in question, my code clears the cell where their username was. So, even if they just saved the workbook, it will clear their name then Excel will ask if they want to save their changes. How do I skip the "Do you want to save your changes" message when Excel is closed? Or, how do I automatically select "Yes"?

Thanks.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Your code could be amended (assuming this is in the before save event in the this workbook module):

Code:
Dim MySaved As Boolean
MySaved = Me.Saved
'Clear name
Me.Saved = MySaved
 
Upvote 0
To suppress the message, wrap it in Application.DisplayAlerts = False and set it back to True at the end.

If you want to save the workbook without their interaction you can use Activeworkbook.Close True. Change it to false if you don't want to save it.

HTH,
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,700
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top