MXL5: Application.Quit in Auto_Open Sub Causes Computer to Hang |
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.
To work around this problem, do either of the following:
For example, instead of using thisUsing Application.OnTime to indirectly call the subroutine containing Application.Quit allows you to avoid hanging your computer. If the Auto_Open subroutine contains Application.Quit, or if the Auto_Open subroutine directly executes a macro that contains the Application.Quit command, your computer will hang.use this:Sub Auto_Open() MsgBox "This is a test." Application.Quit End SubSub Auto_Open() Application.OnTime Now + TimeValue("00:00:02"), "QuitMSExcel" End Sub Sub QuitMSExcel() MsgBox "This is a test." Application.Quit End Sub
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.
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/support/supportnet/overview/overview.aspThe 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-
and the computer will either restart or hang when you select the Restart button.Sorry, a system error occurred.
"Microsoft Excel"
error type 11
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.00a auto open autoopen exit hang lock
Keywords : kbcode kbprg xlmac
Version : MACINTOSH:5.0,5.0a
Platform : MACINTOSH
Issue type : kbprb
Technology :
|
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |