MXL5: Application.Quit in Auto_Open Sub Causes Computer to Hang

ID: Q129434

The information in this article applies to:

SYMPTOMS

In the versions of Microsoft Excel listed at the beginning of this article, if you open a workbook that contains an Auto_Open subroutine that contains the following line of code

   Application.Quit

Microsoft Excel may stop responding (hang) with either a type 1 error or a type 11 error, depending on whether you are running Microsoft Excel for the Macintosh or Microsoft Excel for the Power Macintosh.

WORKAROUND

To work around this problem, do either of the following:

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel 98 Macintosh Edition.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/ 

The following is an example of an Auto_Open subroutine that will cause Microsoft Excel 5.0 to hang when the workbook that contains it is opened:

   Sub Auto_Open()
       Application.Quit
   End Sub

If you open a workbook that contains this subroutine, you will receive one of the following error messages:

   The application "unknown" has unexpectedly quit, because an error of
   type 1 occurred.

   -or-

   Sorry, a system error occurred.
   "Microsoft Excel"
      error type 11

and the computer will either restart or hang when you select the Restart button.

This error will not occur unless the subroutine is an Auto_Open subroutine. For example, when you run the following subroutine

   Sub Test()
       Application.Quit
   End Sub

an error will not occur unless the Test subroutine is directly called by an Auto_Open subroutine.

Additional query words: 5.00 5.00a auto open autoopen exit hang lock

Keywords          : kbcode kbprg xlmac 
Version           : MACINTOSH:5.0
Platform          : MACINTOSH
Issue type        : kbprb

Last Reviewed: June 1, 1999