MsgBox for save and close workbook

mrowe

Board Regular
Joined
Feb 17, 2002
Messages
232
Hi,
I'm trying to include a MsgBox to prompt the user to save their work or not when the work book is closed.

Can any one help?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Why would you want another one when Excel already does this?

You'll need to create a Document On-Close that shows a messagebox.

Need further help? Say so! :smile:
 
Upvote 0
Thanks for your relpy, it was something that was asked by the person I'm doing it for - I agree with you... but I'm not the boss :smile:

Any chance of a hand?
Matt
 
Upvote 0
Not really seeing the point of this one.

If you have already saved your work before closing, Excel will not prompt you to save since there is nothing to save.

If you have changed your workbook since the last save, then Excel will prompt for the workbook to save.

In Effect you would have to cancel the Excel prompt by using:<pre>
Application.DisplayAlerts = false</pre>


Then you would have do a Yes/No msgbox, get the result, do an If...Then
to throw up the "save as" dialogue box. The only difference now is there won't be a "cancel" button on the msgbox.

In effect, all you'll have done is increased the time to close down and save the workbook because you're not using the built in features.

My advice is simply to fake it, use the built-in Excel check and tell your client that you've coded it.

- Sometimes it is OK to call the client an idiot.


_________________<font color = green> Mark O'Brien
This message was edited by Mark O'Brien on 2002-02-22 09:47
This message was edited by Mark O'Brien on 2002-02-22 09:48
 
Upvote 0
This go's into the "ThisWorkBook" module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Me.Saved = False Then Me.Application.Dialogs(xlDialogSaveAs).Show
End Sub

This will pull the Excel Save on Exit dialog. JSW
 
Upvote 0

Forum statistics

Threads
1,223,308
Messages
6,171,332
Members
452,396
Latest member
ajl_ahmed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top