Errors that occur in debugging a class, as if they were raised when calling Property

I (unfortunately) am developing an application in Excel 2000 VBA. I believe that I found that any error that occurs in the properties, functions, or auxiliary debugs of a custom class is as if the error had been raised at the point in the VBA code where the property is being called. That is, the VBE debugger does not bring me to the point in the Class property where the error occurred, but instead where the property was first entered (for example, from a module or module function), this makes it difficult to develop anything larger than the smallest code OO Excel 2000 VBA, since I must step by step execute each method of the class to detect the instructions that cause the error.

Am I missing something or is this a known bug that I have to deal with in Excel 2000? Was it fixed in 2003 or 2007?

Code example:

'''''''''''''''
'In Module1:

Public Sub TestSub1()
    Dim testClass As Class1
    Dim testVariant As Variant
    Set testClass = New Class1
    testVariant = testClass.Property1 'Debugger takes me here...
End Sub

''''''''''''''
' In Class1

Property Get Property1() As Variant
    Err.Raise 666, , "Excel 2000 VBA Sux!" 'But error is actually thrown here.
End Property
+3
source share
4 answers

For Office 2003, you get this behavior when the debugger is configured to break unhandled errors (default setting).

If you want it to break into the Err.Raise line, you need to configure it to break all errors (Tools / Options / General / Error Trapping / Break on All Errors).

I believe this is the same for Office 2000, but I do not have a copy to verify.

+4
source

This page is a very good resource for handling errors in VBA:

+1
source

"" Excel 2003 , , 2007 .

0

Excel 2010 - , .

Chip Pearson:

, Break In.

:

, . - Break On All Errors. , , - , , On Error . - Break On Unhandled Errors. , , On Error. . - Break In Class Module - . , .

The Break In Class Module is the most important module because it will cause the debugger to break a line of code inside the object module, which is actually causing the problem. The Break In Class Module parameter is located in the Options dialog box, available in the Tools menu. It is located on the General tab of the Options dialog box, as shown below.

0
source

All Articles