Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Recovering Macros from Corrupted Workbooks.

Recovering Macros from Corrupted Workbooks

Written by Allen Wyatt (last updated October 31, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


Devarajan ran into a situation where a workbook became corrupted, but he wanted to recover the macro module that was associated with the workbook. (The macros represented quite a bit of development time.) Devarajan wondered how the module could be recovered.

The answer depends, in large part, on how corrupted the workbook really is and where the corruption is located within the workbook. Much has been written about how to recover corrupted workbooks; the following resources will be of interest in this regard:

http://support.microsoft.com/kb/142117 (for Excel 97)
http://support.microsoft.com/kb/179871 (for Excel 2000)
http://support.microsoft.com/kb/820741 (for Excel 2002 and 2003)
http://www.jkp-ads.com/Articles/CorruptFiles.asp

Most of these pages refer specifically to recovering data, not to recovering the macros in a module associated with a workbook. (It is interesting that the Microsoft Knowledge Base doesn't have any articles on recovering data from a corrupted Excel 2007 workbook. Perhaps one will come, with time.) One thing that you might try in order to get your macros is the following:

  1. Open Excel, but not the problem workbook.
  2. Set the calculation mode to manual (Tools | Options | Calculation tab | Manual).
  3. Set the security setting to High (Tools | Macro | Security | High).
  4. Open the troublesome workbook. If it opens successfully, you should see a notice that the macros were disabled. (If the workbook doesn't open, then you might as well shut Excel down; this series of steps won't work.)
  5. Press Alt+F11 to display the VBA Editor.
  6. In the Project Explorer, locate the module you want to save.
  7. Right-click the module name and choose Export File.
  8. Provide a name and location of where to save the module.
  9. Close the VBA Editor and get out of Excel.
  10. With the module saved in its own file, you can now import it into another workbook, as desired.

Another way to attempt recovery is to use OpenOffice, a free alternative to Microsoft Office. The spreadsheet program in OpenOffice will open Excel files, and it isn't as sensitive to some corruption issues.

If this still doesn't work, try using a low-level file manipulation tool that allow you to read files sector by sector from a disk, and then allow you to see the information in each sector. With most types of files this won't be very helpful. In fact, it wouldn't help you recover any data from an Excel workbook. Recovering macros is a different story, however. They are stored in the workbook in plain ASCII text, so you should be able to recognize the macro code and then copy it from the disk tool.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2399) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Recovering Macros from Corrupted Workbooks.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing the Format of Existing Dates

There are a myriad of ways in which a date can be formatted--day first, month first, number of digits in the year, etc. ...

Discover More

Setting Tab Stops Using the Tabs Dialog Box

Aligning different lines in your document is easy. Using the tab stops feature in Word, you can set four different types ...

Discover More

Finding the Number of Significant Digits

When looking at a number, you may wonder how many significant digits it contains. The answer is not always an easy one, ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (menu)

Aborting a Macro and Retaining Control

If you need to exit a macro before it is finished running, you can do it using a brute force method, or you can build in ...

Discover More

Renaming a File

Need to rename a file in a macro? It's easy to do using the Name command, as discussed in this tip.

Discover More

Generating a List of Macros

Got a workbook that has lots and lots of macros associated with it? Here's a way you can get a list of all of those ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.