Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
exiting excel ONLY the workbook will close | Excel Discussion (Misc queries) | |||
Message Box on exiting workbook | Excel Discussion (Misc queries) | |||
Re-establish function on exiting workbook | Excel Worksheet Functions | |||
When opening a workbook, need to ensure user opens in a certain ce | Excel Discussion (Misc queries) | |||
How can I see a copy of a saved workbook before I saved it again? | Excel Worksheet Functions |