Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do you wish to save prompt Kelley Excel Discussion (Misc queries) 1 November 20th 06 05:58 PM
Save Changes Prompt ExcelQuestion Excel Worksheet Functions 4 June 20th 06 11:25 PM
save prompt for user exit, but no save prompt for batch import? lpj Excel Discussion (Misc queries) 1 February 25th 06 03:08 AM
Save prompt MC Excel Discussion (Misc queries) 1 March 7th 05 07:18 PM
Save As... prompt darryl26 Excel Programming 1 August 13th 04 09:31 PM


All times are GMT +1. The time now is 12:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"