5

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

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Chris
  • 210
  • 3
  • 11
  • Yes, definitely. I was not able to find the CAUSE, I simply open a new excel workbook and paste all my code, formatting into it and the problem was solved. Probably due to corrupted workbook. If it's already a giant excel/code. Can you post some detail? – Larry Dec 18 '12 at 09:28
  • @Chris What Larry said could be a better idea to rebuild your sheet unless it's not too much of a hassel. Anyways, you may want to know the particular object you are trying to watch. I believe the object could be the reason too with some incompatible properties you are trying to access.. Can you show us your class code here and which line you guess it's crashing... – bonCodigo Dec 18 '12 at 09:51
  • Hi thanks for the comments. It is one of those situations with code I can't post (Yeah I know its hard to say what the problem is without seeing the code :( ). I did before posting this copy paste the code out of the class and then make the class again. Its got a lot of code in there that I've inherited. What are you guys using to automate rebuilding your spreadsheets? Or did you do this manually @Larry? – Chris Dec 18 '12 at 13:52
  • @bonCodigo Can you give me a couple of examples of incompatible properties? (PS I removed all the modules and saved the sheet, open and repaired the sheet and then added the modules back in and still have the same issue). – Chris Dec 19 '12 at 10:09
  • I didn't copy paste the code. Maybe I'll try that. That will take a while. – Chris Dec 19 '12 at 10:15
  • 1
    @Chris can you at least show us your objects class properties and the watch line it fails? Having a code snippet in a question/answer is in community's best interest :-) – bonCodigo Dec 19 '12 at 10:42
  • @bonCodigo Yeah I know and I agree code snippets are the best, its annoying when you can't post the code :@. It doesn't fail on a specific line the whole excel session crashes when I click on the plus sign in the watch window or the local window, so I can't tell which line it crashes on. Meanwhile any out of the air tips would be much appeciated, for example, a property example that would cause this to happen. – Chris Dec 20 '12 at 11:46
  • Could you rename your secret properties and classes and paste it here? Otherwise it's unlikely anybody will be able to help. – Konstantin Spirin Dec 03 '13 at 07:27

1 Answers1

5

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
Inarion
  • 578
  • 3
  • 14
theStrawMan
  • 235
  • 2
  • 9
  • 2
    Another testimony, just in case it is useful for someone: I had the same problem with one of my classes and to catch it I started commenting out the public methods of the class until I found the offending one. – Clon May 05 '15 at 10:31
  • 1
    Thanks for this. I had added a new getter to a class which made Excel crash when you tried to inspect it. Wouldn't have realized it without your post here. Kind of insane that this happens, but then again, this is VBA. – karl Aug 11 '15 at 11:17