Error message in Excel: "Errors were detected while saving ..."
Problem
Consider the following scenario: You are working on a project to automate Microsoft Office. Therefore, you have opened the Microsoft Visual Basic for Applications editor. An Excel worksheet is open as well, which contains a think-cell Excel data link (see 21. Excel data links).
You delete the Excel worksheet where think-cell's Excel data link resides. Excel may show an error message: "Object required".
If you try to save the Excel file, Excel shows an error message:
"Errors were detected while saving [file name]. Microsoft Excel may be able to save the file by removing or repairing some features. To make the repairs in a new file, click Continue. To cancel saving the file, click Cancel."
When you click Continue, the repair fails.
Excel 2007 or 2010: Excel crashes if you try to insert a new Excel worksheet instead of trying to save the file.
Cause
The problem is caused by a bug in Excel. We have filed a case with Microsoft. If your company has a Microsoft Office Support contract and you want to contact Microsoft to ask for a fix, you may refer to Microsoft case number 114072911657591. The error can be reproduced without think-cell.
Reproduction without think-cell
Please perform the following steps:
- Start Excel with a new empty file.
- Enter 100 in cells A1 and A2 on the first worksheet, Sheet1.
- Select the cells A1:A2 on Sheet1 and press Ctrl + C to copy.
- (Only if you try to reproduce with Excel 2013 or later: Insert a second worksheet. Older Excel versions have three default worksheets, so this is not required).
- Press Alt + F11 to open the Microsoft Visual Basic for Applications editor window, and leave it open.
- Start Word with a new empty file.
- In Word, go to Home > Paste > Paste Special > Paste Link: Microsoft Excel Worksheet Object and click OK.
- In Excel, right-click the Sheet1 tab and click Delete.
-
Try to save the Excel file. Excel shows an error message:
"Errors were detected while saving [file name]. Microsoft Excel may be able to save the file by removing or repairing some features. To make the repairs in a new file, click Continue. To cancel saving the file, click Cancel."When you click Continue, the repair fails.
Excel 2007 or 2010: Excel crashes if you try to insert a new Excel worksheet instead of trying to save the file.
Solution
If you encounter this error, you can save your data in a new Excel document or discard the changes and repair the original document:
Save your data in a new Excel document
To save changes you made to your document, copy the worksheets you changed to a new Excel document and save it.
Repair your Excel document to avoid this error in the future
You can repair your Excel document by deleting any Visual Basic for Applications (VBA) projects from your document. However, simply deleting them in the Visual Basic editor is not sufficient. Please use the following procedure:
- Create a backup of your document.
- Download and run the free Structured Storage Viewer.
- Open your document in the Structured Storage Viewer.
- In the tree view of your document, select _VBA_PROJECT_CUR and press Del to delete it.
- Confirm deletion and close the Structured Storage Viewer.
- Open the document in Excel.
- There will be a dialog box Microsoft Visual Basic > File not found. Hit OK.
- There will be another dialog box Repairs, with Lost Visual Basic project listed. Hit Close.
- Save your document.
You should now be able to delete the worksheet with think-cell links and then save the document.