Can't Find Project or Library; also can't access VBA Codes or "References"

jewkes6000

Board Regular
Joined
Mar 25, 2020
Messages
60
Office Version
  1. 365
Platform
  1. Windows
I have a .xlsm file with a ton of macros. One of my co-workers was using it and suddenly started getting the "Can't Find Project or Library" error. I've researched on the internet and a common solution is to go into the VB editor and check the references; however, I can't even access the reference box. Whenever I open the VB Editor (Alt+F11), I can do anything in the editor. I can select "Tool" then "References"; however, nothing happens when I click it. Further, when I open up a module, I can't see my code. I've attached a screenshot of what this looks like. It's just a blank screen.

A couple things to note:
- It only happens with this Excel file. Other macro enabled files work fine
- With this file, we gate the same issue on both mine and my co-workers computer.
- I've also tried registering a library file by using the run command as explained in the link below, but that didn't work either.
- When I click on a UserForm in the VB Editor, I get an error which says "Module not found" (see 2nd screenshot below)

Any suggestions or help is much appreciated.

Thank you.

1613779443920.png



1613779485611.png
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
damaged file or damaged excel install i am thinking
 

sitewolf

Active Member
Joined
May 4, 2012
Messages
297
I've run into this and resolved it in various ways before....including Tools/References in the VB editor and turning OLE Automation off, save and close, then reopen the file....or copying the VB code from modules into a new file.

But the reason I came here today is because I keep running into this, on multiple files and on multiple devices (not all at the same time, just happens to one periodically)
So MY question is.......why does it keep happening when it's on multiple installs and devices?
For the most part, the macros are still in the editor, I just can't run them.
These are mostly files created sometimes quite a few years ago....has VB code changed and my old coding just starts breaking?
 

jewkes6000

Board Regular
Joined
Mar 25, 2020
Messages
60
Office Version
  1. 365
Platform
  1. Windows
I never found a good reason as to why this happened; however, thus far, it has only happened to one of my colleague (it has hasn't happened to me, although, when it happens to her, that same file doesn't work on my computer either). I think my colleague's computer is not properly linked to Sharepoint and when it's looking for some linked files, I think that's when it happens???? This is just a wild guess.

One way that I have found which fixes it is to us the repair function in Excel. Open Excel, then click, File, Open and browse to the corrupt file. Click the file and the click the down arrow next to the "Open" button and select "Open and Repair...". This has been working for me whenever it has happened to my colleague.
 

ZVI

MrExcel MVP
Joined
Apr 9, 2008
Messages
3,875
Office Version
  1. 2019
  2. 2016
  3. 2010
Platform
  1. Windows

ADVERTISEMENT

Can try to recover the VBA project of that workbook if you PM me link to download it (you may delete all data sheets except of empty one).
To be sure it is your code, do you have previous copy of workbook which is working, or some code from that XLSM?
 

Robert1217

New Member
Joined
Mar 23, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all,

The same here.

I am building large *.xlsb/*.xlsm Excel models including the use of Power query / Power pivot and obviously, VB macros.
Sometimes when opening a file, Excel gives me the “Can’t find project or library” message as well.
When the error occurs, macros can’t be accessed anymore and Excel is crashing soon after, so figuring out what could have caused this (when the particular file has opened) isn’t possible either.

I am working as a contractor for companies which employ hundreds of Excel co-workers and have seen this on various (modern) laptops.

In my experience, this error usually appears on the laptop which the file is saved the last time and I therefore don’t quite understand how appropriate the MS-suggested solutions are (checking/unchecking references dialog boxes etc.) as the file opens perfectly on another machine with exactly the same references checked/unchecked indeed.

The error therefore seems somehow related to the particular file in combination with the hardware on which the file is saved, rather than just the Excel program itself.

Further, the issue doesn’t seem to be related to old/new/32-bit/64-bit etc. laptops, nor the amount of RAM nor types of processor nor VBA/references settings.

Local IT departments / MS consultants don’t have a clue (“what are you talking about, file opens fine over here”…) and I remain very curious what could prevent this from happening in the first place.

Thanks!
 
  • Like
Reactions: dof

jewkes6000

Board Regular
Joined
Mar 25, 2020
Messages
60
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

@*Robert1217 - For me, the issue was just one person and I believe it has something to do with their connection to Sharepoint or OneDrive or some kind of cloud service. The solution that worked for us is the following:
  1. Open Excel (don't open a file through File Explorer)
  2. Click "Open File" and browse to the file you're having the issue with
  3. In the bottom right-hand corner where it says "Open", click the down arrow just to the right of this Open button
  4. Select "Open and Repair..."
This repaired the file so it was usable. Still unsure what is causing the issue. Make sure they are logged into all of their cloud accounts. Other than that, I'm not sure. I'm no expert in this area.
 
Solution

csotstot

New Member
Joined
Jun 1, 2017
Messages
24
I've run into the same issue a number of times with one of our files. It is a file with multiple copies used by multiple people. The issue can affect any user's copy at any time. I have stumbled on a quick fix in our case from a posting for the same issue that someone else had. For us, simply opening a blank .xlsm file gives us access to the reference tools (we lose access to them when the issue arises), we can then reset the lost reference (It's always looking for a Sharepoint path reference to the workbook itself. Once reset, the workbook functions properly again, but I notice that reopening the workbook, the reference no longer exists (not as a missing reference, there is no reference to be lost)...Excel seems to be inserting a spurious reference that removes access to all of the vba code, once you set the reference and save the file, it's apparently no longer needed and disappears...
 

sitewolf

Active Member
Joined
May 4, 2012
Messages
297
I have had this issue many times the past couple years, always with 365 I believe...and while I've found various fixes or workarounds, simply using the open and repair idea is the quickest and easiest method. So I heartily thank jewkes6000 for reminding me of that option.

I had originally thought it had something to do with running macro-enabled files created in prior versions of Excel being run in 365, but I've started running into it with files I only recently created, and with 365. Regardless, it's an annoying bug I could certainly live without because often it's early morning and I'm not fully awake when I suddenly run into this with a file, sometimes with limited time to deal with it. Fixing it period can be a pain, fixing it before the brain is fully functioning just isn't fair :p
 

Anish2408

New Member
Joined
Jun 30, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
@*Robert1217 - For me, the issue was just one person and I believe it has something to do with their connection to Sharepoint or OneDrive or some kind of cloud service. The solution that worked for us is the following:
  1. Open Excel (don't open a file through File Explorer)
  2. Click "Open File" and browse to the file you're having the issue with
  3. In the bottom right-hand corner where it says "Open", click the down arrow just to the right of this Open button
  4. Select "Open and Repair..."
This repaired the file so it was usable. Still unsure what is causing the issue. Make sure they are logged into all of their cloud accounts. Other than that, I'm not sure. I'm no expert in this area.
Worked like a charm - Thank you!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,012
Messages
5,834,920
Members
430,326
Latest member
tomwax46

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top