View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Steve McLeod Steve McLeod is offline
external usenet poster
 
Posts: 6
Default Out of Scope Errors when exiting Excel

I click the File menu and then Exit. Excel starts shutting down. While
shutting down Excel VBA flags objects as missing and opens the debugger.
Sometimes the flagged code is a reference to a control on a sheet, sometimes
it is a global variable, and sometimes it is a sheet reference, and sometimes
Excel exits without starting the debugger. The "End" button is the one on
the debugger prompt that permits the user to enter debugging or just end
execution.

The only reason these errors can occur is that Excel has closed the
referenced object prior to scanning the code that references it. This is
stupid. Why worry about object references when all of them are being closed?
Why try to execute a control event when the application is closing?

--
Pictou


"Steve McLeod" wrote:

I have worksheets with controls and associated event code. When I exit the
Excel I am getting compiler errors in code that references controls and other
objects that have gone out of scope while Excel is shutting down. The VBA
code that is flagged as in error is not consistently the same. How do I get
Excel to shut down without the need to click the "End" button in the VBA
debugger prompt?
--
Pictou