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

青春壹個敷衍的年華 提交于 2019-12-01 20:20:39

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/13929724/viewing-an-object-in-locals-or-watch-window-causes-excel-to-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!