Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing an object in Locals or Watch window causes excel to crash

In Excel when I'm running some code and put a breakpoint in I can look at the values of things in the locals window. In the locals window, when I try to expand a object for the class I've created Excel Crashes with "Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvinience. This also happens if I try to view the object in the watch window.

Any ideas? Or anyone had this before?

Thanks,

Chris

like image 200
Chris Avatar asked Dec 18 '12 09:12

Chris


1 Answers

Check, check again and recheck your class properties, especially your GET code. I had the same error where expanding the a custom class object during debugging caused Excel to crash. Excel essentially runs those GET properties when you expand the object in the locals window, so they must compile and not cause any runtime errors.

Of course I can't say this definitely caused the OP's error without seeing their code, but for me the error was an extremely simple one where a GET property contained a type mismatch:

Private pAccFullArr() As String

Public Property Get accFullArr() As Variant
    accFullArr = pAccFullArr
End Property

should have been

Private pAccFullArr() As String

Public Property Get accFullArr() As STRING()
    accFullArr = pAccFullArr
End Property
like image 175
theStrawMan Avatar answered Oct 06 '22 14:10

theStrawMan