#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
kcdonaldson
 
Posts: n/a
Default msg box at close

I would like a message box to apear when the user closes the workbook that
would remind them to check certain things in the department before they save.
Can anyone help me with the code for this?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Norman Jones
 
Posts: n/a
Default msg box at close

Hi KC,

Try:

'================
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "Your message"
End Sub
'<<================

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module):

******************************************
Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)

Select 'View Code' from the menu and paste the code.

Alt-F11 to return to Excel.
******************************************

---
Regards,
Norman


"kcdonaldson" wrote in message
...
I would like a message box to apear when the user closes the workbook that
would remind them to check certain things in the department before they
save.
Can anyone help me with the code for this?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Norman Jones
 
Posts: n/a
Default msg box at close

Hi KC,

Replace my code with the following:

'=============
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim res As Long

res = MsgBox(prompt:="Have you forgotten to...", _
Buttons:=vbYesNo)

Cancel = res = vbYes
End Sub
'<<=============

Now, if the user responds yes to the message box, the file will remain open;
otherwise, the file closes.

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi KC,

Try:

'================
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "Your message"
End Sub
'<<================

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module):

******************************************
Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)

Select 'View Code' from the menu and paste the code.

Alt-F11 to return to Excel.
******************************************

---
Regards,
Norman


"kcdonaldson" wrote in message
...
I would like a message box to apear when the user closes the workbook that
would remind them to check certain things in the department before they
save.
Can anyone help me with the code for this?





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
Why excel close all files when I just want to close one files hon123456 Excel Discussion (Misc queries) 2 December 8th 10 12:12 PM
close button does not close goplayoutside Excel Discussion (Misc queries) 1 October 11th 05 03:42 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
BLANK EXCEL PAGE STILL EXIST AFTER I CLOSE OUT SPREADSHEET? still learning New Users to Excel 2 May 22nd 05 11:50 AM
How can I close only 1 workbook when I have many open? jpt consulting Excel Discussion (Misc queries) 3 November 30th 04 11:58 PM


All times are GMT +1. The time now is 07:23 PM.

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"