Excel Compiled VBA Corruption - Why Does It Happen?

JohnTravolski

New Member
Joined
Nov 25, 2015
Messages
46
Office Version
  1. 2019
Platform
  1. Windows
Recently I have run into a situation twice in the past week where an Excel .xlsm workbook I open and save on a regular basis started to complain "Can't find project or library" every time I open it.

This is because the workbook has a custom function I defined in the VBA, which apparently became corrupt somehow. If I open the VBA editor with Alt + F11, and I go to the modules in the corrupt workbook, it brings up a window, but rather than showing me the code, it is just a blank window that appears to have frozen pixels underneath it (if I move the window, the pixels don't change, and if there were other windows opened up underneath it, you can still see those windows even after moving it). So I can't even see the project code.

From some cursory research, apparently this is a compiled VBA corruption issue. A suggested solution was to add the registry 32-bit dword "ForceVBALoadFromSource" with a value of 1 to the key "Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Excel\Options". Sure enough, as soon as I did this, it fixed it and the workbook and it opens normally now. If I resave this workbook as a copy, delete the registry dword I added, and then reopen the newly-saved version, the issue goes away.

Apparently the compiled VBA was getting corrupted, and it was suggested it may be related to OneDrive and some syncing issue somehow. However, OneDrive isn't even installed on my computer, and I don't do any type of cloud backup. So I guess something is going wrong during the saving process causing the VBA to be corrupted.

My goal is to understand why this has suddenly happened twice in the past week given it has never happened for years before of regularly updating this workbook on this exact same Excel version. I'm concerned it's a sign of a bigger problem on my system. Given OneDrive isn't installed, do you have any thoughts on why this is happening?

This is Excel 2019 (Version 1807 build 10325). The workbook size is 18 MB. There are only a handful of macros defined in it.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I have never had the VBA go corrupt to the point of not being readable. I have had the "ThisWorkbook" get duplicated and Sheets get duplicated and look like the ThisWorkbook module.

Have you tried saving as .XLSB? Have you tried exporting your VBA Modules, delete them in the WB, and then import them back in?

Sorry I don't have more to offer on the problem.

Jeff
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Excel Compiled VBA Corruption - Why Does It Happen?
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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
Back
Top