Recover Missing VBA Modules After Excel XLSM Crashes
Question details
The user needs to recover inaccessible VBA modules after repeated Excel crashes and prevent further crashes in a macro-enabled XLSM workbook.

- Product
- Microsoft Excel macro-enabled workbook (XLSM) and Visual Basic for Applications (VBA)
- Device & OS
- not provided
- Scenario
- Excel crashes repeatedly, leaving VBA modules unavailable in the Visual Basic Editor and preventing the XLSM workbook from being saved or repaired.
- Observed behavior
- The VBA project may still be embedded in the workbook, but its modules cannot be viewed or exported, and Excel cannot reliably save or repair the file.
Make a copy of the affected XLSM file before opening, repairing, or testing it. Locate any prior workbook versions and exported VBA files such as .bas, .cls, and .frm files, because these are the safest source for restoration.
Restore VBA modules from a known-good backup or exported files
Use this method when you have an earlier workbook version or exported VBA components created before the crashes began.
If the current VBA project cannot be opened in the Visual Basic Editor, do not keep attempting to save over the damaged workbook. Restore code from a verified backup, then bring the code and usable worksheet data into a clean macro-enabled workbook.
In File Explorer, copy the affected .xlsm file and rename the copy before testing. Open only the copy in Excel.
In Excel, select File > New > Blank workbook, then choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm).
Press Alt+F11 to open the Visual Basic Editor. Select File > Import File, then import available .bas modules, .cls class modules, and .frm user forms from a trusted export or backup.
Open the known-good backup or the affected workbook if it still opens, then copy required worksheets or data into the new XLSM workbook using Home > Copy and Home > Paste.
In Excel, select Developer > Macros to run macros individually where appropriate, correct any missing references in Tools > References in the Visual Basic Editor, and save the rebuilt workbook as a new .xlsm file.

Start Excel in Safe Mode and isolate crashing add-ins
Use this method when Excel crashes while opening the workbook or when accessing the VBA project.
Check security software, update Office, and seek VBA extraction help
Use this method when crashes continue after add-ins are isolated or the VBA project remains inaccessible.
Use WPS Office for compatible spreadsheet work while rebuilding the Excel file
WPS Office is a free, lightweight office suite with a familiar spreadsheet interface for opening, reviewing, and moving compatible workbook data while an inaccessible Excel VBA project is being recovered. It can help you continue standard spreadsheet work and migrate files smoothly, but it is not a repair tool for a damaged or inaccessible Microsoft VBA project.

Frequently Asked Questions
Why are my VBA modules missing after an Excel crash?
The modules may still be embedded in the XLSM file, but the VBA project can become inaccessible because of workbook corruption, an Excel crash, an add-in conflict, or interference during file access. Check the project with Alt+F11 on a copy of the file before attempting repairs.
Can Excel recover VBA code from a corrupted XLSM file?
Excel may recover workbook content through File > Open > Browse > select the file > arrow next to Open > Open and Repair, but it may not restore an inaccessible VBA project. Exported modules and known-good backups are the most reliable recovery source.
How do I export VBA modules before a workbook fails?
Press Alt+F11 to open the Visual Basic Editor, select a module in Project Explorer, then choose File > Export File. Repeat this for standard modules, class modules, and user forms, and store the exported files with the workbook version.
How can I tell whether an Excel add-in is causing the crash?
Start Excel with Windows+R and excel /safe. If the workbook is stable, go to File > Options > Add-ins, select COM Add-ins from Manage, choose Go, and disable nonessential add-ins. Re-enable them one by one to identify the issue.
Should I disable Windows Defender or antivirus software to open an XLSM file?
Do not disable protection permanently. If security software is suspected, ask your IT or security team to review the event logs and conduct a controlled, policy-approved test instead.




