VBA Userform error

  • Hi,

    I have some VBA & User forms in an Excel Book that were written in 2005, everything has worked fine on every upgrade to Excel and on 365 up until last week.

    Upon trying to open the workbook it will not open and when I can eventually get to the debugger it comes up with the attached.

    With much fiddling and getting it into safe mode and I disable user form1 it seem to open fine, I can then manually bring up user form1 OK.


    My issue is there are hundreds of spreadsheets in use that now won't open, any ideas what may have gone wrong and a fix?


    Thanks for your help.


  • Hi and Welcome to the Forum :)


    This issue seems to be rather strange ...


    Would you have you recently tried to modify your UserForm ?


    Edit: googling this question, found this stack overflow thread :

    What is the cause of the "path/file access error" error
    The hard part of this error is that it does not occur all the time, but I think it is due to the userforms. The program works as it should most of the time,…
    stackoverflow.com


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

    Edited once, last by Carim ().

  • Feel free to comment

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • I have now narrowed it down to the userform1.show. I have managed to force open the book in safe mode and disabled the command so the userform1 does not show on start up.


    Is there something in the background that can cause this as it is odd, as if the userform1 is then called via a macro when the book is open it appears no problem.


  • It is rare indeed that that line would cause an error. It is more likely to be code in the Initialize or Activate event of that form.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • It is rare indeed that that line would cause an error. It is more likely to be code in the Initialize or Activate event of that form.

    Thanks,

    Could you explain a bit more? How would this suddenly affect 100's of workbooks if nothings changed?

  • When you show a form, it is first loaded into memory and any code in its Initialize event is run (this is usually where the problem with a userform.show line actually is) then the form is displayed and any Activate code is run.


    As a side note, it is generally better in my experience not to run code directly from the Workbook_Open event. If you use Application.Ontime to schedule any startup code (you can use Now as the schedule time), it gives Excel time to finish all its startup processes (particularly necessary when you open the workbook directly from explorer, thereby also loading excel).

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Quick question - are you on version 2212 by any chance? I've seen quite a few reports recently of weird errors with workbooks with userforms on that build. There is apparently a fix in the works.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Quick question - are you on version 2212 by any chance? I've seen quite a few reports recently of weird errors with workbooks with userforms on that build. There is apparently a fix in the works.

    Hi Yes,

    We are on version 2212.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!