MOD2000: Error Handler Code Is Put in the Wrong Place by the VBA Error Handler Add-in

ID: Q236503


The information in this article applies to:
  • Microsoft Office 2000 Developer

Moderate: Requires basic macro, coding, and interoperability skills.


SYMPTOMS

When you use the VBA Error Handler add-in, the error handling code may not be inserted between the beginning and end of the procedure. If the error handling code is outside the procedure and you try to compile the project or run the procedure that calls the error handling code, you may receive the following error message:

Compile error:
Label not defined


CAUSE

You receive this error message when the last line in a module is a comment.

NOTE: You see this same behavior if any other text, such as a variable declaration, is the last line in a module, but using anything other than a comment or an End Sub/Function as the last line of a module causes an error.


RESOLUTION

If you encounter this problem, move the


End Sub 
-or-

End Function 
line so that it comes after the error handling code block.


STATUS

Microsoft has confirmed this to be a problem in the Microsoft Office Developer Tools.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Open one of the programs in the Microsoft Office suite.


  2. Press ALT+F11 to open the Visual Basic Editor.


  3. On the Insert menu, click Module.


  4. Type the following code:


  5. 
    Sub Test()
    End Sub
    
    ' This is a comment below the End statement 
  6. On the Add-Ins menu, click Add-In Manager. Make sure the VBA Error Handler add-in is loaded.


  7. On the Add-Ins menu, click VBA Error Handler.


  8. Under the Add Error Handlers to group, click All Procedures in Current Module, and then click OK.


  9. On the Debug menu, click Compile project name.


Note that you receive the error message mentioned in the "Symptoms" section.

Additional query words: pra subroutine function addin add in

Keywords : kbdta AccCon modVBAErrorHandler
Version : :
Platform : WINDOWS
Issue type : kbbug


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