Hi there
How do I cancel an application exit from VBA?
Hi there
How do I cancel an application exit from VBA?
Helmekki,
As long as a file is open in Excel, you can put the following code in the
"ThisWorkbook" module and it worked for me - it keeps both the file and the
Application from closing:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True: Call YourOtherCodeHere
End Sub
Note: You will need to call some other code or add some code to the above or
you and/or your user will never be able to exit. To work around that, check
out: Application.EnableEvents = False/True.
HTH/
"helmekki" wrote:
>
> Hi there
>
> How do I cancel an application exit from VBA?
>
>
> --
> helmekki
>
>
> ------------------------------------------------------------------------
> helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
> View this thread: http://www.excelforum.com/showthread...hreadid=479941
>
>
If the event declaration has a parameter named 'Cancel', set that
variable to True. Otherwise you can't cancel individual events.
However, you can events from being triggered at all with
Application.EnableEvents = False
Be sure to set it back to true at the appropriate place in code.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"helmekki"
<helmekki.1xkwyb_1130447121.0753@excelforum-nospam.com> wrote in
message
news:helmekki.1xkwyb_1130447121.0753@excelforum-nospam.com...
>
> Hi there
>
> How do I cancel an application exit from VBA?
>
>
> --
> helmekki
>
>
> ------------------------------------------------------------------------
> helmekki's Profile:
> http://www.excelforum.com/member.php...fo&userid=6939
> View this thread:
> http://www.excelforum.com/showthread...hreadid=479941
>
Thank u
It worked fine
Last edited by helmekki; 10-27-2005 at 10:39 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks