You've got an .xls workbook with years of VBA macros built into it — automation routines, custom functions, form controls that your team depends on every day. You know you need to move to the modern .xlsx format. You open Excel, click File → Save As, choose .xlsx, and hit save.
Excel shows a warning. You click OK. The file saves. Later, someone opens it and the macros are gone. Every last line of VBA code: deleted.
This happens constantly, and it's entirely preventable. Here's exactly what you need to know to convert your .xls files to a modern format without losing a single line of code.
This is the single most important thing to understand before you start. The .xlsx format — the standard modern Excel format — cannot contain VBA macros by design. It's a security decision built into the Open XML specification.
When you save a macro-enabled .xls file as .xlsx, Excel will strip out every VBA module, every UserForm, every class module, and every macro-linked button. The warning dialog Microsoft shows is easy to dismiss without fully reading, and the damage is done silently.
The correct format for a macro-enabled workbook in the modern era is .xlsm — the Excel Macro-Enabled Workbook format. It uses the same Open XML structure as .xlsx but includes a separate VBA project container that preserves your code.
| Format | Era | Contains Macros | Notes |
|---|---|---|---|
.xls |
Excel 97–2003 | Yes (BIFF8) | Legacy binary format. Limited to 65,536 rows. |
.xlsx |
Excel 2007+ | No | Modern Open XML. 1M+ rows. No macros allowed. |
.xlsm |
Excel 2007+ | Yes | Modern Open XML with VBA project. This is what you want. |
The rule is straightforward: if your .xls file has macros, convert to .xlsm. If it has no macros, convert to .xlsx.
Before converting, confirm what you're working with. Open the file in Excel and press Alt + F11 to open the VBA editor. In the Project Explorer on the left, look for:
If you see any of these, your file has macros and must be saved as .xlsm.
Excel will not warn you about macro loss when saving as .xlsm because the format supports them. The conversion is straightforward — your data, formulas, formatting, and VBA code all transfer cleanly.
After saving, close the file and reopen it from its new .xlsm location. Then:
Alt + F11 and confirm all your modules are presentKeep the original .xls file as a backup until you've fully validated the .xlsm version.
LegacyLeaps scans your entire file collection, identifies every macro, and converts everything in one pass — preserving VBA code, formulas, and formatting.
Try the Free ScanDeclare Function statements need the PtrSafe keyword for 64-bit Office (see below)STDEV to STDEV.S); both versions work in modern Excel but old names show as compatibility warningsIf your .xls file contains Win32 API declarations — calls to Windows DLLs using Declare Function or Declare Sub — you'll likely see a compile error after converting:
Compile error:
The code in this project must be updated for use on 64-bit systems.
This happens because the old 32-bit API declarations are incompatible with 64-bit Office. The fix is adding the PtrSafe keyword to each declaration:
' Old (32-bit only):
Declare Function GetTickCount Lib "kernel32" () As Long
' Fixed (works on both 32-bit and 64-bit):
Declare PtrSafe Function GetTickCount Lib "kernel32" () As LongPtr
Note two changes: PtrSafe is added after Declare, and the return type changes from Long to LongPtr for pointer-sized values. For a comprehensive walkthrough, see our guide on fixing PtrSafe errors after a Windows update.
If you're dealing with dozens or hundreds of .xls files, manually opening each one in Excel isn't practical. A few options:
You can automate batch conversion using Excel's COM automation via PowerShell. This works for straightforward files:
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$excel.DisplayAlerts = $false
Get-ChildItem -Path "C:\Files" -Filter "*.xls" | ForEach-Object {
$wb = $excel.Workbooks.Open($_.FullName)
$newPath = $_.FullName -replace '\.xls$', '.xlsm'
# xlOpenXMLWorkbookMacroEnabled = 52
$wb.SaveAs($newPath, 52)
$wb.Close()
}
$excel.Quit()
This approach has limits: it won't fix PtrSafe errors, won't audit what broke, and fails silently if a file has a password or corrupted structures.
For files that contain complex VBA, ActiveX controls, or inter-file references, a dedicated migration tool handles the conversion more reliably. LegacyLeaps scans each file first, reports exactly which macros and controls it found, and converts everything in one pass. You see a compatibility report before anything is changed — so there are no surprises.
If your .xls files contain only data, formulas, and formatting — no VBA at all — you can safely convert to .xlsx directly. The process is identical: File → Save As → Excel Workbook (*.xlsx). No macros means no risk of macro loss.
Use the VBA editor check (Alt + F11) described above to confirm there's no code before choosing this path.
Possibly, if you still have the original .xls file. The .xlsx file itself cannot contain VBA code — it was stripped out during the save. If you have the original, convert it to .xlsm as described above. If you don't have the original, recovery depends on whether any backup exists (previous versions in Windows, cloud storage, email attachments).
Yes, with the same requirements as before: the other machine needs Excel with macros enabled. Modern Excel defaults to blocking macros in files downloaded from the internet. Users either need to unblock the file via Properties → Unblock, or your organization needs to configure Trusted Locations.
Migrate to .xlsm. The .xls format is limited to 65,536 rows, uses a binary format that's harder to recover from corruption, and is increasingly flagged as a security risk by modern Office security policies. .xlsm gives you the full modern row limit, better compression, and compatibility with all current Excel features — while keeping your macros intact.
Start with the ones that are actively used. Dormant archives can stay as .xls until you need them. For active files, conversion to .xlsm reduces the risk of format-related issues from future Windows or Office updates.
Download LegacyLeaps and scan your files for free. You'll see exactly which macros, VBA code, and ActiveX controls were found — before converting anything.
Download Free ScannerPractical fixes for legacy Excel and Access problems. No spam.