Microsoft KB Archive/236503

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

Article ID: 236503

Article Last Modified on 8/6/2002

-

APPLIES TO


 * Microsoft Office 2000 Developer Edition

-



This article was previously published under Q236503



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 that this is a problem in the Microsoft Office Developer Tools.



Steps to Reproduce Behavior
 Open one of the programs in the Microsoft Office suite. Press ALT+F11 to open the Visual Basic Editor. On the Insert menu, click Module.  Type the following code: Sub Test End Sub

' This is a comment below the End statement  On the Add-Ins menu, click Add-In Manager. Make sure the VBA Error Handler add-in is loaded.</li> On the Add-Ins menu, click VBA Error Handler.</li> Under the Add Error Handlers to group, click All Procedures in Current Module, and then click OK.</li> On the Debug menu, click Compile .</li></ol>

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

Additional query words: pra subroutine function addin add in

Keywords: kbbug kbpending KB236503

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.