VBA: Force a Workbook to Save
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…
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Saved = False Then
ActiveWorkbook.Save
End If
End Sub
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.
Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
Get answers right away at our AE Excel Support Forums!
Leave a comment
| Trackback


