Excel/Userform beforeclose closes without saving.
I just used the code taken from daveexcel.com for workbook open user form and it works perfectly as i needed.Likewise i just modified it a bit as you had suggested for beforeclose and it also works fine.But what happens is when i close excel the pop up appears and when i close the userform it quits from excel without option for saving.How to modify the code to ask enduser for saving the workbook finally?
The code seen below is entered in workbook module.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
You should not be able to close the userform, it closes by itself.
It asks me if I want to save changes when the userform closes. Maybe your workbook is already saved when you click the close Button.
You can add activeworkbook.save to the unload routine in the regular module to make sure the workbook saves.
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here