Auto Save on Closing Spreadsheet

alexdurc09

New Member
Joined
Sep 21, 2018
Messages
17
Hello all,
I have the below code to automatically save my spreadsheetwhen it is closed down so that people can’t close without saving. However, whenit is closed down, the spreadsheet reopens its self automatically. The only wayto close it down is to exit Excel completely and all spread sheets which are open.
Thanks,
Alex

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'ThisWorkbook Modulecode!

ActiveWorkbook.Save
End Sub

 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try Me.Save instead of ActiveWorkbook.Save and see what happens.
 
Last edited:
Upvote 0
Hi, thank you for your suggestion. Have just tried it but hasn't worked unfortunately. Have you anything else I could try?
Thank,
Ale
 
Upvote 0
The code you are using is standard and works - so there is something else interfering (or possibly a minor corruption)
Is there any other code in ThisWorkbook module?

Perhaps force the user to save the workbook, something like this instead of your code
Code:
If Not Me.Saved Then
   MsgBox "Please save the file before closing"
   Cancel = True
End If
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,953
Members
448,535
Latest member
alrossman

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