VBA – Force a Workbook to Save Before Close

Associated Files Download Links

Force Workbook to Save – Workbook_BeforeClose

I wouldn’t advise using this, but for the sake of experimentation and as a demonstration of ActiveWorkbook.Save:

You can Save a workbook without giving the user a “Yes/No” option with the following code:

Place this in the ThisWorkbook module…

This doesn’t work for multiple workbooks. To make it work with multiple workbooks you’d need to place the code in the personal.xls file or have it loop through all open workbooks.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!

<<Return to VBA Examples