+ Reply to Thread
Results 1 to 27 of 27

Lost Visual Basic Project

  1. #1
    Registered User
    Join Date
    04-14-2006
    Posts
    73

    Lost Visual Basic Project

    Have a project going and have had a disturbing trend develop. I'm working in Excel 2003. Upon opening the file and enabling macros, I started receiving File/Path errors, at which point it would shut down the application. When opened, I have a splash that would come up, but it wouldn't go to the next userform. At this point I would get the error message and the file would be closed. If I then reopened the file, disabled macros, saved under a different file name, and then reopened with macros enabled, everything worked fine, until I shut it down and then tried to reopen, at which point the same error would occur.

    Lately I have simply been getting the Microsoft Excel dialogue box telling me an unexpected error occurred and it had to be shut down. I'm at a loss for what is causing this. The last time this happened, when Excel recovered the file, it told me a repair had been done, and the repair was to basically delete all of the VBA code from the file. Obviously, this is a problem. Ideas?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You need to find the error in the code so we need to see the workbook or the code.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    In This Workbook:
    Please Login or Register  to view this content.
    The splash usually shows before I get the error, but not always, and sometimes it works fine. I can't find any consistency to when or why this is occurring. Here's the Userform activate code in case it helps.
    For the splash:
    Please Login or Register  to view this content.
    The userform activate macro for the Data userform is rather long, and I've stepped through it with no problem. I can post it if necessary. Thanks for taking a look.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Is Reset a macro? If so what is the code in it?


    First try removing the opening of DataForm from the open event, & run it from the splash
    [code]
    Private Sub UserForm_Terminate()
    Data.Show
    End Sub[code]

  5. #5
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    Yes - Reset is a macro that clears data out of the worksheets and sets a few default values. Is it problematic to call a macro from the Workbook_Open event? Before this particular file, I'm not sure I've done anything more than open userforms from there. I'll definitely use your suggestion.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You should be able to call macros from the open event. Check out the userforms first

  7. #7
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    For what it's worth, here's the Reset code:
    Please Login or Register  to view this content.
    Thanks again for your help.

    Rich

  8. #8
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    I moved the code as you suggested, but am getting the same error. Specifically, I get a Path/File Error and after closing this alert I am getting a run-time error 75 (could not find the specified object).

    Since I moved the code, I stepped through it again and got the error as soon as it went to the Data.Show command. I don't understand the error message because a userform called Data does exist. Could this be because there is an object in the Activate event that perhaps doesn't exist (I've made several changes to those objects). I'll check this next, but if this is the problem it will usually step through the code right up to the line of code with the object it can't find.

  9. #9
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    Don't know if this makes a difference, but when the userform Data is loaded, rather than an Activate event, I have actually programmed it as an Initialize event. Could this be part of the problem?

  10. #10
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    Well, I changed the event from Initialize to Activate - made no difference, still getting the error. It acts as if there is no actual userform called Data, but there is. I'm really stumped.

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Can you attach the workbook, zip it if necessary

  12. #12
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    Here's the workbook. I cut way down on the file size and checked the modified version to verify I'm still getting the error, which I am. If it works once, close it down and try it again. I don't get the error every time I open it.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    An update on my progress. I thought that the problem might have something to do with the userform, so I created a new one. I've continued to test and try to isolate the problem, which continues to be sporadic. I am however getting an error message I have yet to ever see in excel. This occurs on opening the file and enabling the macros. After the splash has been unloaded and the next userform loaded, I'm getting a run-time error referred to as an "automation error - the object invoked has disconnected from its clients." I looked at the help screen on this, but it really wasn't much help. I've attached an updated workbook for anyone that would like to take a look. I'm really lost as to what is causing this. Thanks for your help.
    Attached Files Attached Files

  14. #14
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I don't get an erro, the splash loads followed by the next form.

  15. #15
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    I was afraid of that. The problems I'm experiencing are quite unusual given my experience with VBA projects. I don't see any reason for these errors to be occurring.

    I've recently begun working on a different laptop (this one had previously been used by a coworker, but he didn't work with VBA at all), and this is the first VBA project that I've fully developed on it. Is it possible that excel has somehow become corrupted and I simply need to reload it? If so, do I need to create a new file for this project, since reloading excel will not fix whatever problems exist with this file?

  16. #16
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    Still trying to fix this. I've completely removed the userform_activate macro for the Interface userform, so all that should be happening is that the it is loaded once the Splash userform is unloaded. I continue to receive a path/file access error, followed by a runtime error 75 - could not find the specified object - after the splash is unloaded. The debugger highlights the code Interface.Show. I'm at a loss as to why this is happening since no other code is being executed when this userform is loaded.

    Here's the exact sequence that's giving me this error:
    Open the file
    Enable macros
    Splash loads and unloads
    The Interface userform loads successfully
    Close the userform using the X (rather than the Finish button)
    Exit file without saving
    Reopen the file
    The error will be received after the Splash is unloaded

    I've tried this on more than one computer with the same result. If someone wants to test the attached workbook (please use version 3, rather than the first two posted) I'd appreciate any feedback. Thanks.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    For anyone sticking with me on this, thanks for your patience. I've gone all the way back to something very basic. It appears that anytime I use the ControlSource property to link a control (for example, a text box) in a userform to a worksheet, I'm getting this same path/file error when I go to open it. I started with a new workbook, created a new userform, placed a text box in it and linked it to one of the worksheets, and I get the same error as with the workbook that I originally posted about. If I remove the link to the worksheet, then I no longer get the error.

    This seems to be a problem with the application itself, which I really didn't expect. Has anyone else had a similar experience? Is there anything I can do besides reloading Office? Thanks for your help.

  18. #18
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    I'm going to attach this workbook so that you guys can verify I'm not crazy. This is the new workbook I just created and it causes a file/path error most of the time when it is opened. I guess I'm going to reinstall Office and have several shots of hard liqueur while I'm at it so that I can perhaps alleviate my stress level over this. Cheers!
    Attached Files Attached Files

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You could start with detect & repair -- it takes five minutes.
    Entia non sunt multiplicanda sine necessitate

  20. #20
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    Already did it.

  21. #21
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I had problems initially, ran CodeCleaner, and it ran fine.

  22. #22
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    What did codecleaner correct, and where can I get codecleaner?

  23. #23
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

  24. #24
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    I ran codecleaner and did some more testing. I'm still getting the error, but only after I save the file. Regardless of whether or not I make any selections on the userform, if I save the file, I get a file/path error after closing and then reopening. If I open it and run codecleaner again, it then works again, until I save it.
    Last edited by racudd; 10-26-2008 at 08:54 PM. Reason: clarity

  25. #25
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi,

    Here's a couple of long-shot directional questions which Shg maybe able to say straight out that they won't help (I'm just guessing...):

    * Does VBE have references (under Tools in VBE) or Addins (in VBE or Excel) relating to an "external" projects/files that aren't on the new laptop?

    Also, what happens if you change the name of the form from "Interface" to something more likely to be unique eg "UFInterface" (ie short for Userform Interface) then rerun Codecleaner before testing?
    "Interface" sounds & looks suspiciously like a standard Excel expression & it's possible that Excel/VBE may be getting confused about what it's meant to be loading or unloading.

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  26. #26
    Registered User
    Join Date
    04-14-2006
    Posts
    73
    Rob - thanks for the input. I've tried different names for the userform to no avail, and there's no issue with references. I think I've got some bigger problems - don't know how I got them, but some radical steps may be necessary as I have done a fair amount of programming and all of a sudden I have some things behaving in a most peculiar way. This file has worked well right up until about a week ago, and now there seems to be nothing I can do to make it work right. I don't think I've ever experienced this level of frustration. It seems like something may have simply corrupted my excel application, although I just can't see how that could have happened (I have the usual virus controls, etc.). I'm going to ask one of the moderators to remove my attachments as I don't want this to result in anyone else having problems.

  27. #27
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi Racudd,

    Best of luck :-)

    Here's some irrelevant chatter...
    I've had similar problems (excel crashing when userforms are in one of the open files) recently & found that it seemed to occur randomly but even after compiling the code/running codecleaner & smartindenter. Although no errors were identified, I was getting desperate & started to play around (I have no knowledge of what impact this could have had & don't recommend it!) in the "automation" section of Excel's Addin dialogbox ticking & unticking a couple of items. I made no actual changes but possibly something I did caused some sort of refresh??? which fixed the problem of Excel crashing.

    Rob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1