Getting System Error &H80070057 (-2147024809) - excel

I've been running a workbook with a few macros in it for a couple of years, and I've suddenly started getting this error thrown at me for some navigational buttons (shapes linked to macros that are simply ThisWorkbook.Sheets("sheet_name").Activate).
Other Macros within the workbook seem to work OK, but I can't get into the VBA editor to see any of the code anymore - I get to the VBA interface, but when I go to open the Module, nothing happens.
And to cap it all off, when I try to save the workbook, I'm just getting an error saying 'Document not saved'.

I had the same issue. I opened the VBA code module and then selected Debug then Compile VBAProject. I then closed the Visual Basic Editor and the error seems to have been resolved. Have only had the issue the once so can't be 100% sure it will work in every instance but worth a go.

Suggest you open a backup copy of this file (if you have one), export the broken module and then in your current file, remove the broken module and import the clean version.

We had the same problem in a file that was drawing data from an external source and saving itself automatically every minute. What worked for us was just replacing the entire file with a backup from 2 days ago.
We also had the "Document Not Saved" error, which was solved by upgrading the file from .xls to .xlsx

Just came across this error - for me it seems to affect any code opening docs via external links. Ran the debug suggested above and fixed issue.

Related

PHPSpreadsheet writing charts generate warning when opened with Office Excel

Good Morning. I made a PHP script to generate an .xlsx file containing some charts in different sheets.
I used a self-made PHP framework using COMPOSER and libraries such PHPSPREADSHEETS (version 1.23)
It worked fine till some months ago.
Now I noticed that when the script generate the .xlsx file, opening with office Excel, I get a warning telling me that there are some problem with part of content and after another one:
Records restored: Drawing from the part /xl/drawings/drawing1.xml
(Draw shape)
Clicking OK anyway the file (and charts) are showed correctly.
I also tried to save the file from Excel with "Save as" and the new file is opening without warnings.
I searched online this issue but I didn't find anything to solve this.
Anybody had the same problem?
The same problem is happening using the default example by PhpSpreadsheet: link

VBA Workbooks stop working with upgrade to Excel 365 - VBA Compiling Issue?

Since upgrading to Excel 365, my company has been having all sorts of trouble with VBA-supported Excel workbooks crashing or not functioning properly. The issues have popped up in various workbooks and various departments, including seemingly simple VBA workbooks. I've discovered a fix (see below) but it's not sustainable.
The Issues
The various issues we have experienced are listed below. Note, these issues only occur when you open a file in Excel 365 desktop. The same files, when opened in the Excel 365 browser app or in Excel 2016 will work fine. Also, all these issues happen at random. A user may have been working in a file for weeks and then the next time they open the file they get one of these errors.
"Can't find project or library" errors even when we are using the standard set of libraries and basic VBA. Then when you open the VBA Editor window, all the VBA screens are essentially frozen up and the library list is inaccessible.
Excel hard crashes or locks up when opening these files and enabling VBA. Note, the crash only occurs when the VBA is enabled. If you open a file without enabling VBA, it will work fine (though obviously you can't use any of the code).
The file opens seemingly fine, but the VBA doesn't work and once again, everything is locked up when you access the VBA editor window.
"unhandled win32 exception occurred" error
when executing a command, getting an error 32809 which seems to indicate the compiled VBA has been corrupted
The Fix
Opening the VBA Editor window, then selecting Debug -> Compile VBAProject seemingly fixes the issue. I've yet to experience any of the above issues where the file had been manually compiled this way. The problem with this is that every time you add code to a file or any time you add a new tab to a file, you have to go in and perform this manual compile again.
Yes, apparently adding a single tab in a file changes the workbook structure enough that it is necessary to compile again. The Compiled VBAProject selection will be greyed out. But adding a tab (or adding new VBA) will un-grey it and require another manual compile or the problems start occurring again.
This fix also works to repair files where the above issues are occurring. To fix those files, you can:
Make sure "Disable Trusted Documents" and "Disable VBA macros with notification" are toggled on in your security settings so that VBA doesn't automatically run when you open a file.
Open the file with the errors but do not enable the VBA.
Go to the VBA Editor window, select Debug -> Compile VBAProject.
Save the file, close it, reopen it, enable the VBA, and everything works fine again.
But again, this isn't sustainable because all my users will have to remember to go compile VBA any time they add a new tab to a workbook.
Help?
Has anyone found a more sustainable fix to this issue? Is there a bug with the Excel 365 Desktop automatic compiler that Microsoft is working on?
I think I perhaps found an answer in this thread:
https://social.msdn.microsoft.com/Forums/en-US/814ac2ce-ab45-45dc-8c6a-8ef0775d189a/excel-64bit-crashes-when-activating-macros-but-excel-32bit-does-not?forum=exceldev&prof=required
Per that thread – “the cause is that Excel does not correctly save the compile state of the VBA code and 64 bit Excel cannot recover from that issue when opening the afflicted Excel file (32 bit usually can). A fix was released for only Excel 2016 and not for other versions". That would indeed confirm that it is a bug within Excel and explains why we only see the issue with 365 64 bit Excel.
That also explains why my manual compile fix works. Based on the article I found, there is a more sustainable fix. You can change Excel’s registry and force VBA to compile accurately.
To implement the permanent fix:
Open the start menu and type “reg” and select the “Registry Editor”
Navigate to: Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Excel\options
On the Edit menu, point to New, and then click DWORD Value.
Type ForceVBALoadFromSource, and then press Enter.
In the Details pane, right-click ForceVBALoadFromSource, and then click Modify.
In the Value data box, type 1, and then click OK.

Corrupt VBA Project Module Not Found Error

I have a workbook that was saved yesterday afternoon, and was working perfectly. I have opened it this morning, and none of the modules in the VBE are 'found'. Visually I can see them all sitting there.
When trying to open any of these modules to edit the code, the windows are greyed out, as below.
When I try exporting the code modules, I get the 'Module Not Found' errror.
Does anyone know a) why this has happened, and b) how can I fix this?
I thought initially it was the instance of my Excel, so have restarted the PC.
Any help is appreciated!
I managed to find a workaround to this problem, so sharing the solution in the event that someone else comes across a similar problem.
It seems that the VBA Project got corrupt somehow. Below, find some suggestions and workarounds in trying to solve something similar in the future.
This is what worked for me. Convert the .xlsm file to a .xls file. You can do this by changing the file extension when renaming the file.
You can also try to convert to .zip file type, and then convert back to .xlsm. Note: convert COPIES of your original, just in case.
Other suggestions (as Chris Nelisen suggested) are:
Export your VBA modules regularly
Save different versions as you are building
My workaround, works perfectly:
Open Excel in safe mode (pressing and holding Ctrl while you start
the program, or by using the /safe switch (excel.exe /safe) when you
start the program from the command line)
Open corrupted workbook (from safe mode, File->Open-> navigate)
Do not enable macro if asked
Make sure macro is present (Alt+F11) - not necessary
Save as new workbook
Close safe mode excel
Open saved workbook as usual
This is a well-described issue, and it exactly matches what I have just experienced (even including the fact that I haven't been versioning recently).
My file has an xlsb suffix. Resaving with a different suffix did not work for me on the same PC, but I emailed the file to another PC, opened it, saved as xlsm, sent it back to the original machine and it now works fine again. I can even re-save with my preferred xlsb suffix and it still works.
I've also run this script to make a backup of my modules:
Sub ExportVbaModules()
'Acknowledgements to Andy Pope [ozgrid thread 60787]
Dim objMyProj As VBProject 'if error, go to VBA editor - tools - References - Microsoft Visual Basic-Extensibility5.3
Dim objVBComp As VBComponent
Set objMyProj = Application.ActiveWorkbook.VBProject
For Each objVBComp In objMyProj.VBComponents
If objVBComp.Type = vbext_ct_StdModule And objVBComp.Name <> "" Then
objVBComp.Export "C:\Users\MyName\VbaBackups\" & objVBComp.Name & ".txt"
End If
Next
End Sub
The And objVBComp.Name <> "" stops it from erroring when it encounters a corrupted module but turned out not to be necessary as the 'fixed' file contained no corrupted modules.
Since that export routine is so fast (40 modules / 100kb saved in <1s) I will be assigning it to a button on the ribbon with a better naming convention for the files it creates.
I copied my .xslm file from my PC to my OneDrive account.
I open the file on my iPad OneDrive account and then export to Excel for iOS. The file opens and says links and macros are disabled. I then save a copy of the file back to the OneDrive account. I go back to my PC and open the file from OneDrive. I re-establish the links.
The macros are from a backup. This is an issue if you aren't backing up your macros.
Do you have this file on OneDrive?
If yes, I was facing that issue, and resolved restoring the last save. If you open OneDrive site (onedrive.live.com), find the file, and select Version History. Download the penultimate.
When this happens on 64 bit Excel, I simply open the exact same file in 32 bit Excel and the macros re-appear.
When this happens on 32 bit Excel, I simply open the exact file in 64 bit Excel and the macros re-appear.
Try to open the excel file in repair mode and save as the file one more time.
Open and Repair
I tried everything suggested and nothing worked. I could only see the module when I opened my VB editor. It was not available through the view macros ribbon shortcut. I was unable to export the module or copy it to a new workbook.
What finally worked for me was emailing it to myself, downloading it through my 365 outlook account via a web browser, and then the code was there.

Get "Microsoft Excel has stopped working" message

I'm running MS Office 2010 on Windows 7 Professional.
I’ve been experiencing this problem periodically for the last month or so, not all the time, but probably once or twice a week.
I’m working on the VBA portion of a fairly complex workbook. I start the day by making a copy of the previous day’s workbook, and make any subsequent code changes on the copy. When I’m finished I’ll run VBA Code Cleaner, do a Debug, Save then exit Excel. I also save a backup copy. I’ll then reopen & close both of these workbooks a number of times just to satisfy myself that everything is still working.
The next day I’ll wake the computer and try to open these files, and as soon as the VBA code starts to run I’ll get the “Microsoft Excel has stopped working” message. This can happen to either the main file or the backup file, and sometimes both.
If I open the bad file with the shift key down, I can get into the VBE area OK, but when I do a Debug or try to run VBA Code Cleaner I get the same message.
The only way I’ve found to recover from this is to:
Manually export the code
Save the file as an xlsx file, thus expunging all the code.
Save the xlsx file as a new xlsm/xlsb file, and then import the exported code.
I just today found another way to recover is to save the file as “xls”, then re-save as xlsb/xlsm, that somehow seems to “clean” something.
After the recovery everything is fine again, at least for a few days.
What I’ve tried so far:
Searched the internet, including StackOverflow, for possible solution.
Run various virus checkers (MS Essentials, Malwarebytes, SuperAntiSpyware)
Repaired MS Office 2010.
Uninstalled and re-installed MS Office 2010
Removed all add-ins
Uninstalled Dropbox
Started using a new user profile.
I came across several articles that suggested xlsb files were prone to corruption, so I started saving as xlsm files. Everything went well for about a week, and I thought I’d resolved the problem. However, it’s now started happening with the xlsm files too, so I’m back to square one.
I’m running out of ideas - the next thing I might try would be re-installing Windows 7, but I really hope to avoid doing that! I would really appreciate any suggestions. Thanks.
Well, I believe I may have found my problem. I noticed that one of my class objects wasn't always terminating correctly, due to it being referenced in a different class. I fixed that, and now it's been 11 days without any problem (touch wood). So I'm reasonably confident that this was the root cause. But I must admit I'm still not quite sure why this occasionally corrupted the workbook.

Excel crashes when loading file that contains userform

Excel crashes when opening files that contain a userform
This is a known problem with a known solution workaround which is to delete a file called Excel.box from here:
C:\Users\SlowLearner\Application Data\Microsoft\Forms\Excel.box
According to this forum post the purpose of the Excel.box (& Word.box) file is:
Files such as Winword.box and Excel.box are associated with the
Control Toolbox you see when you are designing a UserForm in the
Visual Basic editor. The files contain information about the layout of
the Control Toolbox (additional tab pages, controls that have been
added or removed, custom icons, ...) If a user has never modified the
Control Toolbox in any way, there will probably be no .box file. By
deleting a .box file, you will restore the Control Toolbox to its
default (factory preset) configuration - this is the only way to do
that. Sometimes, the .box file becomes corrupted and must be deleted.
There are no negative side effects to deleting it.
Unfortunately Excel.box returns :(
It would seem that for most users the problem is fixed by deleting the file, sadly not for me.
I'd like to understand what is causing this problem to recur. A few points to note:
this (touch wood) is not impacting MS Word on my PC
I am using Office 2010, 64 bit version on Win10
I have not made any conscious change to form settings
if I delete the file > start Excel > UN-DELETE the file: everything works :-/
some other experiences with this issue here
For the time being I'll just check for and delete the file before launching Excel, but this is hardly an acceptable solution for the long term. Appreciate thoughts for a proper fix... TIA
Additional Information:
I have not fully explored the crash but so far it happens when:
starting the application by opening an xl?.m file with a userform
application does not get past the splash screen
crashes with the application's CRASH screen (... encounted an error...)
starting the application with a blank worksheet then adding a userform
crashes immediately with the applications CRASH screen displayed (see below)
The above crash happened after rebooting my PC, had a chance to explore it some more.
First I opened the file I had been working on (contains userforms):
annoyingly it opened without crashing
I did NOT enter the IDE
I closed the file (Excel closed normally)
Then I created a new worksheet
I opened the VBA IDE
right-click 'add UserForm' - Excel crashed immediately
(I aborted the recovery / search for a solution attempt)
Then I re-opened the file I had been working on
opened the VBA IDE (the project is PW protected)
the very instant that I entered the PW and hit enter Excel crashed
crash was same both times...
Safe Mode:
Crash still happens in safe mode - steps to reproduce:
Run: Excel /safe
Open VBA IDE
r-click add userform
crashes immediately
Creation of the EXCEL.box file
Based on visually observing the folder which had the Excel.box file I did some tests to try and see when it was created. Basically it seems to appear when one of the following happens:
- the UserForm tools box is closed
- the IDE is closed (after showing the userform)
I've also now tried to modify the userform toolbox by removing everything from it. Excel is still crashing after every restart of the application (which is odd as I was not able to crash it like that earlier).
Office Repair - not tested (yet)
Reluctant to try Office Repair as based on the following quote from here (scroll down: pg 1 reply 8 by Steve IT) I'm not expecting it to work :-/ (but will try if no other suggestions surface).
Thanks for the continued suggestions, however I have tried a repair and also removed Visual Studio 2013 and Office altogether (just in case VS was interfering) and reinstalled both, but it still throws the errors reported previously.
Other user profiles
Created a brand new user called 'test'. Test has the exact same problem.
This problem eventually resolved itself, not sure why. I continued to use Excel normally and it continued to crash so I would delete the offending .box file and start over...
As of Nov 2017 Excel no longer crashes with respect to this issue; my best guess is there was an automatic update that resolved the issue.
Looks like this issue still occurs and it is not just limited to Excel but also Powerpoint.
The fix as mentioned above works where you move / delete any files in the below folder location resolves the issue.
C:\Users\%username%\Application Data\Microsoft\Forms
It is highly likely that this error is caused by bad code in a macro or an Add-In that uses forms. The problem is replicating this can be difficult so you have to debug this in some way when it does crash out.
POWERPNT.box
EXCEL.box
are some of the files that get generated, where Excel or Powerpoint crash on the splash screen.
Try adding the command
ThisWorkbook.VBProject.VBComponents("UserForm").Activate
just before your
"UserForm".Show line.

Resources