Workbook_BeforeClose Event and Cancel Option

E

Excel Monkey

The following below displays a message when a workbook is closed. However if
the user hits the cancel button when prompted with the options prior to
close, this code still creates the message. This is becuase this event is
triggered before the user is presented with the close options. How do you
get around this. Is there another event that I can use to verify if in fact
the file has been closed.


Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Cancel = False Then
Msgbox("Book closed")
End If

End Sub
 
S

Simon Lloyd

Yes of course they will, you need to substitute one of the message boxes
with your desired action, to cancel the operation or show the workbook
as Saved or save the workbook.
This works but the user will then be prompted again with the Windows
message
box as well.

Thanks

EM


Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)
Code Cage Forums'
(http://www.thecodecage.com/forumz/showthread.php?t=86505)


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top