Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Cancel user's changes but save other changes

Hi,

I've modified the workbook before close function as follows...

Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Not Me.Saved Then
RetVal = MsgBox("Do you want to save the changes you made to '"
& Me.Name & "'?", vbExclamation + vbYesNoCancel)
Select Case RetVal
Case vbYes
Me.Save
Case vbNo
Me.Saved = True
Case vbCancel
Cancel = True
Exit Sub
End Select
End If

// my code with some changes

Me.Save

End Sub

If the user specifies 'No' to changes, then how to I cancel any changes
by the user, but still perform some of my own changes and then save
those, and then close the workbook ??

I want to perform my changes at the very last moment - i.e. without
giving the user an opportunity to cancel closing the workbook after the
code has run.

Basically I'm looking for an alternative to "fooling" excel with the
me.saved=true bit, e.g. me.discardanychanges (or something similar !)

Some assistance would be much appreciated !

Thanks in advance

Jeremy

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Cancel user's changes but save other changes

I think you would have to re-open the workbook, apply your changes, then
close it down. This of course would mean that your code would need to be
elsewhere.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

wrote in message
oups.com...
Hi,

I've modified the workbook before close function as follows...

Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Not Me.Saved Then
RetVal = MsgBox("Do you want to save the changes you made to '"
& Me.Name & "'?", vbExclamation + vbYesNoCancel)
Select Case RetVal
Case vbYes
Me.Save
Case vbNo
Me.Saved = True
Case vbCancel
Cancel = True
Exit Sub
End Select
End If

// my code with some changes

Me.Save

End Sub

If the user specifies 'No' to changes, then how to I cancel any changes
by the user, but still perform some of my own changes and then save
those, and then close the workbook ??

I want to perform my changes at the very last moment - i.e. without
giving the user an opportunity to cancel closing the workbook after the
code has run.

Basically I'm looking for an alternative to "fooling" excel with the
me.saved=true bit, e.g. me.discardanychanges (or something similar !)

Some assistance would be much appreciated !

Thanks in advance

Jeremy



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
macro save a workbook whilst increasing file no shrek Excel Worksheet Functions 0 November 10th 05 02:40 PM
Protect Workbook vs Worksheet?? Dan B Excel Worksheet Functions 3 November 7th 05 09:02 PM
Save as Msg box Bob Umlas, Excel MVP Excel Discussion (Misc queries) 0 August 29th 05 09:56 PM
How to CANCEL file SAVE PROMPT when MACRO is running? Stuart Macro Muppet Excel Discussion (Misc queries) 3 August 11th 05 12:26 PM
Protecting Workbook Paul Cooling Excel Discussion (Misc queries) 2 March 7th 05 11:55 AM


All times are GMT +1. The time now is 06:50 AM.

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"