Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cancel an application exit from VBA?
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cancel an application exit from VBA?
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" wrote in message ... 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cancel an application exit from VBA?
Thank u It worked fine -- helmekki ------------------------------------------------------------------------ helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939 View this thread: http://www.excelforum.com/showthread...hreadid=479941 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to get userform Cancel button to invoke Exit Sub in calling macro? | New Users to Excel | |||
Cancel/Exit Sub | Excel Discussion (Misc queries) | |||
Exit Code Upon Cancel On Type 8 Input Box | Excel Discussion (Misc queries) | |||
InputBox / VBA question ok = print, cancel = exit | Excel Worksheet Functions | |||
Cancel Exit on duplicate | Excel Programming |