Forum Discussion

Kendethar's avatar
Kendethar
Iron Contributor
Sep 15, 2021

Need Help - Userform Error Resulting in Excel Crash - "Automation error Exception occurred"

Greetings Excel Programmers,

 

     I've been experiencing a periodic error while testing code to one of my UserForms that causes Excel to crash without saving my work. 

It's not all the time, or even most of the time, but happens particularly if I've reopened after previously having it open (and ran or partially ran) before. It can be the initializing event or clicking a button inside it or such as. Therefore, while I do have all 3,921 code lines of it doing what I need perfectly, I currently deem the overall UserForm not fully reliable due to the seemingly random error.

 

This is the UserForm (following the click of my button) working fine:

 

     Any thoughts on what could cause this error and what it is? Anything helps and I'd love to be educated! ^_^

 

     Thanks!

   

4 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    Kendethar 

    Without the file, it is very difficult to determine where this might be coming from.

    You would have to guide the VBA code step by step to see where the code stops or where the suspected error can be.

    stepped through it (you can use F8).

     

    if you take out userform.showfrom your code, everything works?

     

    Here is some information if the error is in the user form.

    VBA: "Automation Error. Exception occurred." when using UserForm

     

    Another suggestion that involves a lot of work,
    Copy the user form and all sheets into the new workbook.

     

    I hope that I could help you with this information in your projects.

     

    NikolinoDE

    I know I don't know anything (Socrates)

     

     

     

    • Kendethar's avatar
      Kendethar
      Iron Contributor
      NikolinoDE, thank you for the response! I use F8 all the time and won't help here since the error occurs at a whim before even getting into the code. Copying into a new workbook didn't help it. I couldn't find a way the link you provided could help my case since Alex (on StackOverflow) stated that without the UserForm, his/her code still worked without any issues. And, all my code is thoroughly verified and works fine but something is wrong with the UserForm, like Alex's case. Since I'm working in a single workbook, perhaps, it's a memory issue you think? Also, I wish I could provide helpful code but 1) it's all part of the UserForm containing 3,921 code lines, and 2) correlates to the overall workbook structure (900KB and 12,440 code lines)
      • NikolinoDE's avatar
        NikolinoDE
        Platinum Contributor

        Kendethar 

        This is a very ... but very long debugging to find the error.

        Unfortunately, I can't help without the file here, my knowledge of the error of regenerating this vba code without the corresponding workbook is limited.

        My guess is that it could be due to one or the other user form of the error.

        But there can also be a SUB - Seperate procedure that could be outside the user form and when the work folder is opened, the procedure runs immediately and no user form is found because it only opens afterwards, the error occurs.

        This procedure could also be in another worksheet / module.

         

        Anyway and as I said I am not a VBA guru, I would have to have the file (without sensitive data) to run the VBA code individually.

         

        Thank you for your understanding and patience

         

        NikolinoDE

        I know I don't know anything (Socrates)

Resources