![]() |
How to promt users to save their work?
For my program, all new entries are in red. When the user clicks th
close button of the workbook, i want to do a msgbox to prompt users t save. when they save, the font becomes black. this way, when they ope the workbook again, they cannot make changes to the entries. attache is the coding. I dont think my code is working because when the clos button is pressed, its the default excel msgbox. Sub ActiveWorkbook_beforeClose() Dim Msg, Style, Title, Response Msg = "Are you sure you want to exit? No changes are allowed afte closing of the workbook." Style = vbYesNo + vbQuestion Title = "Important!" Response = MsgBox(Msg, Style, Title) If Response = vbYes Then ActiveWorkbook.Save Else: End If . End Su -- Message posted from http://www.ExcelForum.com |
How to promt users to save their work?
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean) if SaveAsUI then cancel = true End if End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim Msg, Style, Title, Response Msg = "Are you sure you want to exit? No changes are allowed after closing of the workbook." Style = vbYesNo + vbQuestion Title = "Important!" Response = MsgBox(Msg, Style, Title) If Response = vbYes Then 'code to change font color Application.EnableEvents = False ActiveWorkbook.Save Application.EnableEvents = True Else: Cancel = True End If End Sub Untested. -- Regards, Tom Ogilvy "shirley " wrote in message ... For my program, all new entries are in red. When the user clicks the close button of the workbook, i want to do a msgbox to prompt users to save. when they save, the font becomes black. this way, when they open the workbook again, they cannot make changes to the entries. attached is the coding. I dont think my code is working because when the close button is pressed, its the default excel msgbox. Sub ActiveWorkbook_beforeClose() Dim Msg, Style, Title, Response Msg = "Are you sure you want to exit? No changes are allowed after closing of the workbook." Style = vbYesNo + vbQuestion Title = "Important!" Response = MsgBox(Msg, Style, Title) If Response = vbYes Then ActiveWorkbook.Save Else: End If . End Sub --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 05:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com