Windows – Excel “Can’t find Project or Libary” – but which one

microsoft excelmicrosoft-excel-2016vbawindows 10

Using Office 2016. I have an Excel file with VBA. Whenever I open it, I get the error "Can't find Project or Library". Excel immediatlely closes.

I opened Excel and, without opening the file, looked at References. There was one labeled "UNSAVED: VBA Project". When I tried checking it, I got an error. (Sorry, I don't remember exactly what it said — something about having to save it when the file was open.)

Since the, the "UNSAVED: VBA Project" has stopped appearing. There are no entries that say "MISSING".

Open-and-Repair (on the real version) causes the same crash. Opening in Safe Mode doesn't help the issue. However, I can open it in Protected View without its crashing.

I saved a copy without VBA and it worked.

ADDITIONAL: There's a pivot table in the workbook that's connected to an external database.

There's also a Workbook_Open macro that asks the user if he/she wants to run a second macro that updates the pivot table. However, when I block the macros from running, the file still crashes without the Workbook_Open, so the pivot table never tries to update.

Best Answer

I seem to have found a workaround. At some point, when I opened the file in Protected View, I was still able to go to the Visual Basic editor and see its modules. I exported them.

As I said, I had saved a copy as an xlsx file (without the VBA modules). I imported the modules into this version and saved it as xlsm. This version seems to have no problems.

Related Question