Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How to ensure workbook is saved before exiting Excel?

Need to find "fool-proof" method of ensuring Users save Excel workbooks
before exiting program. This has been a huge problem in the past. Can this
be done with a macro?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,071
Default How to ensure workbook is saved before exiting Excel?

Kathy
This macro, placed in the ThisWorkbook module, will fire whenever the
user issues a close command (whenever the user clicks on "Close"). The macro
checks if the workbook has been saved, and will save it if not. The
workbook will then close. Come back if you need more. Otto
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.Saved = False Then
ThisWorkbook.Save
ThisWorkbook.Saved = True
End If
End Sub

"Kathy Love" <Kathy wrote in message
...
Need to find "fool-proof" method of ensuring Users save Excel workbooks
before exiting program. This has been a huge problem in the past. Can
this
be done with a macro?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default How to ensure workbook is saved before exiting Excel?

Even fools can break a macro. But a macro is the closest you will come.

http://www.microsoft.com/office/comm...9-B6753CDAC8C6



Kathy Love wrote:

Need to find "fool-proof" method of ensuring Users save Excel workbooks
before exiting program. This has been a huge problem in the past. Can this
be done with a macro?


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default How to ensure workbook is saved before exiting Excel?

Every time I come up with something foolproof an even bigger fool comes
along. Can a macro force a save at the end... yes. But that is good and bad.
There are times in the world where you have mucked things up so badly that
you want to exit without saving. If we force the save then your users will
complain in that circumsatance. Additionally if they do not enable macros or
have security set to high then the macros do nothing.

That being said here is the macro...

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
If .Saved = False Then .Save
End With
End Sub

Right click the XL icon beside File in the upper left corner of the scrren
and select view code. Paste the aboce code into the code window.
--
HTH...

Jim Thomlinson


"Kathy Love" wrote:

Need to find "fool-proof" method of ensuring Users save Excel workbooks
before exiting program. This has been a huge problem in the past. Can this
be done with a macro?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to ensure workbook is saved before exiting Excel?

I wouldn't do this.

You may find that a user deleted way too much (on purpose or by accident) and
wants to close the file without saving.

If you make the save automatic, then you'll have a different problem--maybe
worse (depending on the changes and the state of your backups).



Kathy Love wrote:

Need to find "fool-proof" method of ensuring Users save Excel workbooks
before exiting program. This has been a huge problem in the past. Can this
be done with a macro?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 348
Default How to ensure workbook is saved before exiting Excel?

Kathy Love wrote:
Need to find "fool-proof" method of ensuring Users save Excel workbooks
before exiting program. This has been a huge problem in the past. Can this
be done with a macro?

I have to agree with the other posters who warn about this. I seldom
want to exit Excel without saving, but when I do I really want to revert
to the previous saved version of the spreadsheet. Perhaps adding a
message box to the macro, one of those ridiculous "Do you really want to
save the file before quitting?" may be appropriate, but that will most
likely antagonize your users.

Bill
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,071
Default How to ensure workbook is saved before exiting Excel?

The other responders bring up some good points. You know your situation and
your users better than we do. Unless you have a malicious user who
intentionally wants to not save a changed file, perhaps a message box
telling him that the file has not been saved and asking him if he wants to
save it before closing, would be more appropriate. Your call. If yes, here
is the same macro with the message box. HTH Otto
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.Saved = False Then
If MsgBox("This workbook has not been saved." & Chr(13) & _
"Do you want to save it before closing?", 20, "Workbook not
saved") = vbYes Then
ThisWorkbook.Save
ThisWorkbook.Saved = True
End If
End If
End Sub

"Kathy Love" <Kathy wrote in message
...
Need to find "fool-proof" method of ensuring Users save Excel workbooks
before exiting program. This has been a huge problem in the past. Can
this
be done with a macro?


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
exiting excel ONLY the workbook will close Brandon Excel Discussion (Misc queries) 12 May 27th 10 09:59 PM
Message Box on exiting workbook cufc1210 Excel Discussion (Misc queries) 1 September 30th 09 02:39 PM
Re-establish function on exiting workbook Colin Hayes Excel Worksheet Functions 4 January 5th 09 02:55 PM
When opening a workbook, need to ensure user opens in a certain ce Gover Excel Discussion (Misc queries) 4 April 11th 07 03:06 PM
How can I see a copy of a saved workbook before I saved it again? Norma Excel Worksheet Functions 2 May 11th 05 10:31 AM


All times are GMT +1. The time now is 08:46 AM.

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

About Us

"It's about Microsoft Excel"