Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prompt to save changes
Hi,
I tried to search for this answer, I have a routine that executes on Private Sub Workbook_BeforeClose(Cancel As Boolean) HideSheets DeleteCM End Sub but before the Hidesheets and DeleteCM execute I would like to prompt the user if they would like to save the changes, only if the select 'Yes' should the Hidesheets and DeleteCM execute - any help is appreciated. Regards. Sanjay |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prompt to save changes
Something like (not fully error-tested):
Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error GoTo ErrorHandler Application.EnableEvents = False iResponse = MsgBox("Do you want to save the changes you made to " _ & Name & "?", vbYesNoCancel + vbExclamation, "Microsoft Excel") If iResponse = vbYes Then HideSheets DeleteCM Save Close ElseIf iResponse = vbNo Then Close False Else End If ErrorHandler: Application.EnableEvents = True End Sub -- Vasant "sanj" wrote in message ... Hi, I tried to search for this answer, I have a routine that executes on Private Sub Workbook_BeforeClose(Cancel As Boolean) HideSheets DeleteCM End Sub but before the Hidesheets and DeleteCM execute I would like to prompt the user if they would like to save the changes, only if the select 'Yes' should the Hidesheets and DeleteCM execute - any help is appreciated. Regards. Sanjay |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prompt to save changes
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ans As Long ans = MsgBox("Save changes (Y/N)?",vbYesNo) If ans = vbYes Then HideSheets DeleteCM End If End Sub -- HTH Bob Phillips "sanj" wrote in message ... Hi, I tried to search for this answer, I have a routine that executes on Private Sub Workbook_BeforeClose(Cancel As Boolean) HideSheets DeleteCM End Sub but before the Hidesheets and DeleteCM execute I would like to prompt the user if they would like to save the changes, only if the select 'Yes' should the Hidesheets and DeleteCM execute - any help is appreciated. Regards. Sanjay |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prompt to save changes
Hi Bob:
Won't this give rise to a duplicate save prompt (the built-in one)? Regards, Vasant "Bob Phillips" wrote in message ... Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim ans As Long ans = MsgBox("Save changes (Y/N)?",vbYesNo) If ans = vbYes Then HideSheets DeleteCM End If End Sub -- HTH Bob Phillips "sanj" wrote in message ... Hi, I tried to search for this answer, I have a routine that executes on Private Sub Workbook_BeforeClose(Cancel As Boolean) HideSheets DeleteCM End Sub but before the Hidesheets and DeleteCM execute I would like to prompt the user if they would like to save the changes, only if the select 'Yes' should the Hidesheets and DeleteCM execute - any help is appreciated. Regards. Sanjay |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prompt to save changes
If MsgBox("Save Changes?", vbYesNo) = vbYes Then
HideSheets DeleteCM End If "sanj" wrote: Hi, I tried to search for this answer, I have a routine that executes on Private Sub Workbook_BeforeClose(Cancel As Boolean) HideSheets DeleteCM End Sub but before the Hidesheets and DeleteCM execute I would like to prompt the user if they would like to save the changes, only if the select 'Yes' should the Hidesheets and DeleteCM execute - any help is appreciated. Regards. Sanjay |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prompt to save changes
Thanks I will try it out!
Regards, Sanjay "Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ... Something like (not fully error-tested): Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error GoTo ErrorHandler Application.EnableEvents = False iResponse = MsgBox("Do you want to save the changes you made to " _ & Name & "?", vbYesNoCancel + vbExclamation, "Microsoft Excel") If iResponse = vbYes Then HideSheets DeleteCM Save Close ElseIf iResponse = vbNo Then Close False Else End If ErrorHandler: Application.EnableEvents = True End Sub -- Vasant "sanj" wrote in message ... Hi, I tried to search for this answer, I have a routine that executes on Private Sub Workbook_BeforeClose(Cancel As Boolean) HideSheets DeleteCM End Sub but before the Hidesheets and DeleteCM execute I would like to prompt the user if they would like to save the changes, only if the select 'Yes' should the Hidesheets and DeleteCM execute - any help is appreciated. Regards. Sanjay |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prompt to save changes
Hi Vasant,
I have no idea what Hidesheets or DeleteCm does, and the message is odd to me, but I haven't added any save code as such. Bob "Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ... Hi Bob: Won't this give rise to a duplicate save prompt (the built-in one)? Regards, Vasant "Bob Phillips" wrote in message ... Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim ans As Long ans = MsgBox("Save changes (Y/N)?",vbYesNo) If ans = vbYes Then HideSheets DeleteCM End If End Sub -- HTH Bob Phillips "sanj" wrote in message ... Hi, I tried to search for this answer, I have a routine that executes on Private Sub Workbook_BeforeClose(Cancel As Boolean) HideSheets DeleteCM End Sub but before the Hidesheets and DeleteCM execute I would like to prompt the user if they would like to save the changes, only if the select 'Yes' should the Hidesheets and DeleteCM execute - any help is appreciated. Regards. Sanjay |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Do you wish to save prompt | Excel Discussion (Misc queries) | |||
Save Changes Prompt | Excel Worksheet Functions | |||
save prompt for user exit, but no save prompt for batch import? | Excel Discussion (Misc queries) | |||
Save prompt | Excel Discussion (Misc queries) | |||
Save As... prompt | Excel Programming |