WD97: VBA Stops and Does Not Enter Break Mode When "Break on Unhandled Errors" Selected

ID: Q238190


The information in this article applies to:
  • Microsoft Word 97 for Windows


SYMPTOMS

If you set Visual Basic for Applications error trapping to Break on Unhandled Errors and a module that raises an error is within the ThisDocument class module, the execution of the Visual Basic for Applications code does not continue after the error is encountered; nor does a break into the code occur, as documented. In addition, when errors do occur, the dialog box is different than expected.


CAUSE

The ThisDocument module is a class module and therefore error trapping in this module behaves differently for the Break on Unhandled Errors and Break on All Errors settings.

With the Break on Unhandled Errors setting, breaking within class module code is disabled; whereas with the Break on All Errors and Break in Class Module settings, breaking within class modules is enabled for error trapping, and the code that handles these error trapping conditions is different. Local error handling within the ThisDocument class module behaves as expected.

This trapping behavior with the Break on Unhandled Errors setting allows the code within the class modules to be treated as private data not to be exposed when errors occur. Although explicit error handling is recommended to obtain expected results and provide proper clean up when errors occur, the Break on Unhandled Errors setting provides a generic level of error handling.


MORE INFORMATION

Microsoft Visual Basic for Applications has three levels of error reporting:

  • Break on Unhandled Errors


  • Break in Class Module


  • Break on All Errors


To set these in the Visual Basic for Applications Editor, click Options on the Tools menu, and then click the General tab.

Additional query words:

Keywords :
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: August 27, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.