Running Macro Causes Reference File to Save somewhere else

%3CLINGO-SUB%20id%3D%22lingo-sub-2098209%22%20slang%3D%22en-US%22%3ERunning%20Macro%20Causes%20Reference%20File%20to%20Save%20somewhere%20else%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2098209%22%20slang%3D%22en-US%22%3E%3CP%3EI%20can't%20seem%20to%20replicate%20this%20error%20but%20it%20happens%20at%20least%20once%20a%20week.%20I%20open%20a%20file%20where%20I%20created%20some%20script.%20Does%20not%20matter%20if%20it%20is%20an%20older%20file%20or%20a%20newer%20one%20and%20I%20get%20the%20dreaded%20error%20%22Can't%20find%20Project%20or%20Library%22.%20This%20means%20that%20the%20Reference%20Library%20is%20missing%20a%20Module%2FTool%20that%20it%20can%20no%20longer%20reference.%20I%20scratch%20my%20head%20and%20wonder%20for%20a%20moment%2C%20%22I%20did%20not%20make%20any%20changes%20to%20my%20tool%20references%20so%20how%20can%20this%20be.%20To%20further%20agitate%20me%20When%20I%20open%20VBA%20Editor%20and%20select%20Tool%20Reference%20the%20sheet%20does%20nothing.%20Won't%20show%20me%20tools%20and%20now%20the%20code%20has%20disappeared.%20I%20can%20see%20the%20modules%20in%20the%20project%20window%20but%20the%20sheet%20is%20blank.%3C%2FP%3E%3CP%3ESo%20first%20I%20have%20to%20fix%20it.%20Usually%2C%20I%20can%20fix%20it%20by%20first%20closing%20out%20of%20all%20Excel%20Apps.%20Then%2C%20while%20holding%20down%20Ctrl%20and%20clicking%20on%20a%20new%20Excel%20app%20to%20open%2C%20I%20open%20Excel%20in%20Safe%20mode.%20I%20open%20the%20file.%20Then%20I%20go%20into%20VBA%20Editor%20and%20select%20Tools%20Reference%20and%20I%20can%20see%20that%20one%20of%20my%20files%20instead%20of%20being%20stored%20in%20with%20the%20system%20files%20it%20is%20normally%20saved%20to%2C%20it%20has%20been%20saved%20to%20my%20C%20Drive%20Documents.%20When%20I%20go%20look%20there%20the%20file%20is%20not%20there.%20However%2C%20if%20I%20search%20for%20the%20file%20in%20my%20system%20files%20(C%3AProgram%20Files%5CCommon%20Files%5CMicrosoft%20Shared%5CVBA)%20I%20find%20it%20and%20re-sync%20it.%3C%2FP%3E%3CP%3EBut%20what%20is%20crazy%20to%20me%20is%20how%20did%20that%20file%20location%20change%20in%20the%20first%20place%3F%20Has%20anyone%20else%20experienced%20this%20issue%20more%20than%20a%20few%20times%3F%3C%2FP%3E%3CP%3EI%20am%20100%25%20certain%20it%20is%20nothing%20in%20my%20code%20causing%20this%20to%20occur.%3C%2FP%3E%3CP%3EI%20think%20the%20problem%20relates%20to%20when%20Excel%20has%20a%20large%20file%20or%20several%20files%20open%20causing%20it%20to%20run%20at%20a%20high%20PC%20Utilization%20rate%2C%20Excel%20begins%20to%20act%20very%20crazy.%20When%20this%20occurs%20and%20I%20start%20shutting%20things%20down%2C%20the%20next%20time%20I%20re-open%20the%20file%20is%20when%20I%20will%20notice%20the%20file%20reference%20error.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2098209%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2369172%22%20slang%3D%22en-US%22%3ERe%3A%20Running%20Macro%20Causes%20Reference%20File%20to%20Save%20somewhere%20else%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2369172%22%20slang%3D%22en-US%22%3EI%20am%20sure%20someone%20has%20an%20answer%20to%20this%20issue.%20It%20just%20happened%20again%20to%20me%20on%20three%20separate%20occasions.%20Files%20I%20have%20used%20for%20a%20few%20weeks%20or%20months%20work%20and%20save%20just%20fine.%20Then%20one%20day%20I%20go%20to%20save%20and%20get%20the%20dreaded%20Excel%20has%20found%20an%20error%20and%20is%20unable%20to%20save%20this%20file.%20We%20can%20repair%20blah%2C%20blah%20blah%2C%20then%20go%20to%20repair%20and%20save%20in%20different%20location%20and%20same%20error.%20Looping%20like%20an%20endless%20EDM%20concert.%20When%20I%20go%20into%20my%20VBA%20the%20modules%20are%20solid%20white%2C%20the%20project%20modules%20are%20there%20and%20will%20let%20you%20select%20them%20but%20no%20code%20in%20the%20module.%20When%20I%20try%20and%20select%20the%20reference%20library%2C%20nothing%20will%20happen%2C%20can't%20access%20it%20now.%20However%2C%20when%20I%20open%20the%20file%20in%20Safe%20Mode%20I%20am%20able%20to%20access%20the%20modules%20and%20Reference%20Library%20where%20I%20see%20Visual%20Basic%20For%20Applications%20reference%20file%20location%20is%20showing%20C%3A%5CUsers%5Cmyname%5CDocuments%5C%20where%20I%20have%20the%20workbook%20itself%20saved.%20The%20library%20reference%20is%20normally%20located%20in%20the%20Microsoft%20shared%5CVBA%5CVBA7.1%5CVBE7%2CDLL%20which%20is%20where%20the%20file%20is%20currently%20it%20is%20not%20in%20my%20documents%20folder.%20Somehow%2C%20Microsoft%20has%20changed%20that%20reference%20library%20file%20but%20not%20actually%20placed%20the%20file%20there.%20This%20is%20crazy...%20If%20anyone%20runs%20into%20this%20issue%20HERE%20IS%20THE%20TEMPORARY%20FIX...%20Close%20the%20file%20and%20loose%20your%20changes%20you%20made.%20Close%20anything%20in%20Excel%20you%20may%20have%20opened.%20Then%20while%20holding%20the%20cntrl%20button%20select%20the%20Excel%20Application%20and%20a%20box%20will%20pop%20up%20asking%20if%20you%20want%20to%20open%20in%20Safe%20Mode.%20Say%20Yes.%20This%20will%20disable%20macros%20but%20still%20allow%20you%20to%20have%20access%20to%20it.%20You%20won't%20need%20to%20access%20this%20most%20times%20this%20occurs%20and%20you%20can%20simply%20save%20the%20file.%20Close%20it%20and%20re-open%20it%20(not%20in%20safe%20mode)%20and%20the%20file%20works%20again.%20Maybe%20for%20a%20few%20days%20or%20months%20but%20it%20will%20probably%20happen%20again%20at%20some%20point%20without%20any%20reason%20as%20to%20why.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2376700%22%20slang%3D%22en-US%22%3ERe%3A%20Running%20Macro%20Causes%20Reference%20File%20to%20Save%20somewhere%20else%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2376700%22%20slang%3D%22en-US%22%3EI%20was%20truly%20hoping%20to%20get%20some%20support%20in%20this%20community%20but%20I%20guess%20I%20will%20take%20my%20questions%20to%20MrExcel%20community%20instead.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2379618%22%20slang%3D%22en-US%22%3ERe%3A%20Running%20Macro%20Causes%20Reference%20File%20to%20Save%20somewhere%20else%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2379618%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F612943%22%20target%3D%22_blank%22%3E%40heylookitsme%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20you're%20running%20your%20macro%20and%20before%20your%20macro%20ends%20its%20procedure%2C%20someone%20opens%20your%20reference%20file%20as%20read%20only%2C%20what%20would%20happen%20to%20the%20rest%20of%20the%20procedure%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

I can't seem to replicate this error but it happens at least once a week. I open a file where I created some script. Does not matter if it is an older file or a newer one and I get the dreaded error "Can't find Project or Library". This means that the Reference Library is missing a Module/Tool that it can no longer reference. I scratch my head and wonder for a moment, "I did not make any changes to my tool references so how can this be. To further agitate me When I open VBA Editor and select Tool Reference the sheet does nothing. Won't show me tools and now the code has disappeared. I can see the modules in the project window but the sheet is blank.

So first I have to fix it. Usually, I can fix it by first closing out of all Excel Apps. Then, while holding down Ctrl and clicking on a new Excel app to open, I open Excel in Safe mode. I open the file. Then I go into VBA Editor and select Tools Reference and I can see that one of my files instead of being stored in with the system files it is normally saved to, it has been saved to my C Drive Documents. When I go look there the file is not there. However, if I search for the file in my system files (C:Program Files\Common Files\Microsoft Shared\VBA) I find it and re-sync it.

But what is crazy to me is how did that file location change in the first place? Has anyone else experienced this issue more than a few times?

I am 100% certain it is nothing in my code causing this to occur.

I think the problem relates to when Excel has a large file or several files open causing it to run at a high PC Utilization rate, Excel begins to act very crazy. When this occurs and I start shutting things down, the next time I re-open the file is when I will notice the file reference error.

4 Replies
I am sure someone has an answer to this issue. It just happened again to me on three separate occasions. Files I have used for a few weeks or months work and save just fine. Then one day I go to save and get the dreaded Excel has found an error and is unable to save this file. We can repair blah, blah blah, then go to repair and save in different location and same error. Looping like an endless EDM concert. When I go into my VBA the modules are solid white, the project modules are there and will let you select them but no code in the module. When I try and select the reference library, nothing will happen, can't access it now. However, when I open the file in Safe Mode I am able to access the modules and Reference Library where I see Visual Basic For Applications reference file location is showing C:\Users\myname\Documents\ where I have the workbook itself saved. The library reference is normally located in the Microsoft shared\VBA\VBA7.1\VBE7,DLL which is where the file is currently it is not in my documents folder. Somehow, Microsoft has changed that reference library file but not actually placed the file there. This is crazy... If anyone runs into this issue HERE IS THE TEMPORARY FIX... Close the file and loose your changes you made. Close anything in Excel you may have opened. Then while holding the cntrl button select the Excel Application and a box will pop up asking if you want to open in Safe Mode. Say Yes. This will disable macros but still allow you to have access to it. You won't need to access this most times this occurs and you can simply save the file. Close it and re-open it (not in safe mode) and the file works again. Maybe for a few days or months but it will probably happen again at some point without any reason as to why.
I was truly hoping to get some support in this community but I guess I will take my questions to MrExcel community instead.

Hi @heylookitsme 

So you're running your macro and before your macro ends its procedure, someone opens your reference file as read only, what would happen to the rest of the procedure?

Can't say I follow what your asking. If I have a file open with Write access and I am running a procedure against it and someone opens the same Excel file as read-only, both would be two separate actions because the file is not a shared file. The reference file for each person resides on their C Drive in the Microsoft Library folders. One factor I have found that could be contributing to this error is Microsoft becomes extremely unstable when you have some large files open. Microsoft needs a built in procedure that calculates the processor and ram usage to determine if opening a file will cause the program to not run correctly and prevent the user from opening a new file until one is shut down. I would much rather be told I can't open another file then to open one and have strange behaviors occur that are not explainable.