Reputation: 291
I am getting an error saying "Can't find project or library" error message when I try to run a VBA project. I am trying to go into the References to see if there is something there that is causing an issue, but when I click on it, it does nothing.
Any suggestions?
Upvotes: 10
Views: 44981
Reputation: 11
I managed to get a workaround for this error.
I was working off of an excel file (macro-enabled workbook) that was stored in my OneDrive, via the desktop interface when this morning. When I opened the file this morning I was suddenly greeted by the "Can't find object or library" error.
To fix it:
This might not work for everyone, but I thought I'd put it down here just in case someone had the same cocktail of circumstance.
Upvotes: 1
Reputation: 35
Same error as user, script and file were working fine beforehand but today no dice. Using AVB's answer but expanded for clarity.
Upvotes: 1
Reputation: 1
What worked for me:
Upvotes: 0
Reputation: 11
After opening in Safe Mode, go in to VBA and under Debug -> Compile VBA Project
Upvotes: 1
Reputation: 31
This worked for me - a. Copy/paste the problematic file to a new location. The error seems to be resolved in the file in the new location. b. Delete the problematic file in the original location (optional) c. Copy/paste the corrected file back to the original location.(optional)
Upvotes: 3
Reputation: 31
I also managet to fix it by disabling all macros, saving the file, and then enabling them from the "Macro Security" in the Developer tab.
Upvotes: 3
Reputation: 1
I just fixed this issue by getting somebody else on the network in my office to go into the file (which worked for them), then saving it as a trusted file. I suppose this would work by emailing a copy of the file to a different device and going into it on there. While on the different device you can also go into VBA Editor > Tools > References then untick all that aren't necessary. This may or may not be necessary. More technical solutions may be available but this seems to be a simple one that worked for me.
Upvotes: 0
Reputation: 25
This can happen for any number of reasons, as VBA and excel are very sensitive. What i would suggest is unprotecting your workbook in any way that it is protected for now. Then try accessing your file via "safe mode" by holding ctrl when opening excel. Take the time to back up any important VBA codes. If you can't fix the errors in safe mode you may need to recreate the workbook with the saved VBA codes.
Also if you have a personal XLSB workbook it may have been corrupted. Go to your excel's XLSB file location and check by opening it and seeing if there are any issues.
I recently had this issue because i protected a sheet that VBA was trying to access when running a code so make sure everything is in order of when it was last working.
Upvotes: 1
Reputation: 53
This has happened to me twice in the last week. For me not only did nothing open under "tools / references" but although the VBA modules were visible they were completely empty. I don't know the cause, but I speculate that it is some combination of:
The first time I managed to retrieve the situation, through a complex procedure; I'm not sure what part of the process worked the magic and for me it's not replicable. The second time (this morning) I adopted a simpler procedure.
Happy bunny - for now.
Upvotes: 2
Reputation: 3
This has happened to me before. As usual, I'd suggest restarting Office. If that does not work, then go to Control Panel> Uninstalled Software> Microsoft Office. click on "Modify" and then once the wizard comes up, select "Repair".
Upvotes: 0