How to Convert XLS to XLSX in Bulk (Without Losing Macros or Data)

May 27, 2026 · 9 min read

You have a folder — maybe a shared drive, maybe a file server — with hundreds or thousands of .xls files that need to become .xlsx. Doing it one at a time through File > Save As is not realistic. You need a bulk conversion process that handles macro detection, preserves data integrity, and doesn't require you to babysit every file. This guide walks through every approach, from free PowerShell scripts to automated tools, so you can pick the one that fits your situation.

In this article

  1. Why bulk conversion matters now
  2. Before you start: the pre-conversion checklist
  3. Method 1: PowerShell script (free, manual)
  4. Method 2: VBA macro from within Excel
  5. Method 3: Automated conversion tools
  6. The macro problem: why blind conversion destroys VBA
  7. Post-conversion validation
  8. Common errors and fixes
  9. FAQ

Why Bulk Conversion Matters Now

Microsoft has been nudging organizations away from .xls for nearly two decades, but the urgency has increased. Modern Excel versions still open .xls files, but they do so in Compatibility Mode — a reduced-functionality state that prevents you from using features like dynamic arrays, Power Query improvements, and the expanded row limits of .xlsx. More critically, many cloud-based tools and APIs either don't support .xls at all or handle it poorly.

If your organization is migrating to Microsoft 365, moving files to SharePoint, or integrating Excel data with Power BI or Python-based workflows, .xls files become a bottleneck. The binary BIFF format is harder for third-party tools to parse, and every .xls file sitting on your file server is a small liability — one that gets harder to deal with the longer you wait.

The good news: bulk conversion is a solved problem. The bad news: doing it wrong can silently strip VBA macros from files that depend on them. The rest of this guide ensures you avoid that outcome.

Before You Start: The Pre-Conversion Checklist

Before you convert a single file, run through this checklist. Skipping it is how organizations end up with broken spreadsheets and angry users.

  1. Back up everything. Copy the entire source directory to a separate location. This is non-negotiable. If anything goes wrong during conversion, you need the originals intact.
  2. Inventory your files. How many .xls files are you dealing with? Are they scattered across subdirectories? Are there .xla (add-in) or .xlt (template) files mixed in? A simple dir /s *.xls on Windows or find . -name "*.xls" on Mac/Linux gives you a count and location list.
  3. Identify files with macros. This is the critical step. Any .xls file containing VBA code must be converted to .xlsm, not .xlsx. Converting it to .xlsx strips all macro code without warning. You cannot tell from the file extension alone — all .xls files use the same extension regardless of whether they contain macros.
  4. Check for external references. Spreadsheets that link to other .xls files by path (e.g., ='C:\Reports\[budget.xls]Sheet1'!A1) will break if you convert the referenced file but not the referencing one, or vice versa. Map your dependencies first.
  5. Decide on your output structure. Will converted files go in the same directory? A parallel directory tree? Will you delete the originals after validation? Plan this before you start.

Skip the manual inventory

LegacyLeaps scans your entire folder and tells you exactly which files have macros, which have formula issues, and which will convert cleanly — free.

Try the Free Scan

Method 1: PowerShell Script (Free, Manual)

This is the most common DIY approach. It uses Excel's COM automation interface to open each .xls file and save it as .xlsx. You need Excel installed on the machine running the script.

$sourcePath = "C:\LegacyFiles"
$destPath = "C:\ConvertedFiles"

$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$excel.DisplayAlerts = $false

Get-ChildItem -Path $sourcePath -Filter "*.xls" -Recurse | ForEach-Object {
    $workbook = $excel.Workbooks.Open($_.FullName)

    # Check for VBA macros
    $hasMacros = $false
    try {
        $hasMacros = $workbook.VBProject.VBComponents.Count -gt 0
    } catch {
        # VBA project access may be restricted
    }

    $relativePath = $_.DirectoryName.Replace($sourcePath, "")
    $outputDir = Join-Path $destPath $relativePath
    if (!(Test-Path $outputDir)) { New-Item -ItemType Directory -Path $outputDir -Force }

    if ($hasMacros) {
        $outputFile = Join-Path $outputDir ($_.BaseName + ".xlsm")
        $workbook.SaveAs($outputFile, 52) # 52 = xlOpenXMLWorkbookMacroEnabled
    } else {
        $outputFile = Join-Path $outputDir ($_.BaseName + ".xlsx")
        $workbook.SaveAs($outputFile, 51) # 51 = xlOpenXMLWorkbook
    }

    $workbook.Close($false)
    Write-Host "Converted: $($_.Name) -> $(Split-Path $outputFile -Leaf)"
}

$excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null

Limitations of the PowerShell approach

Method 2: VBA Macro from Within Excel

If you're more comfortable in VBA than PowerShell, you can write a macro that does essentially the same thing from inside Excel. The logic is identical — loop through files, detect macros, save as the appropriate format. The advantage is that you don't need to deal with COM object lifecycle management. The disadvantage is that you're running the conversion inside an Excel instance, which is even slower and more prone to crashes with large batches.

For most teams, the PowerShell approach is more practical. The VBA approach makes sense if you're converting a small batch (under 50 files) and don't want to open a terminal.

Method 3: Automated Conversion Tools

When you're dealing with hundreds or thousands of files — especially across an organization with multiple file servers and shared drives — scripting your own solution starts to cost more in engineer time than it saves. This is where purpose-built tools earn their keep.

A good bulk conversion tool should handle these things that scripts typically don't:

LegacyLeaps handles all of this. The free scan phase analyzes every file in your batch without modifying anything, then gives you a detailed report of what will happen during conversion. You review the report, approve the conversion, and the tool processes everything — routing macro files to .xlsm, flagging formula issues, and generating a conversion log you can audit.

The Macro Problem: Why Blind Conversion Destroys VBA

This deserves its own section because it's the single most common cause of data loss during bulk .xls conversion.

The .xlsx format, by design, cannot contain VBA macros. When you save an .xls file as .xlsx, Excel strips all VBA code — modules, class modules, UserForms, event handlers, everything. It does warn you during manual Save As, but in a bulk script, there's no interactive prompt. The code just disappears.

Real scenario we see regularly: An IT team writes a PowerShell script to convert all .xls files to .xlsx. The script runs overnight. The next morning, the accounting department's month-end close workbook — which has 15 years of VBA automation built into it — opens as a plain .xlsx with all macros gone. The original .xls files were overwritten because the script saved to the same directory. No backup. The VBA code is unrecoverable.

The solution is straightforward: detect macros before converting, and route those files to .xlsm. The PowerShell script above includes basic detection, but it requires enabling VBA project trust settings and doesn't catch every case (like workbooks with empty VBA projects that still need the .xlsm container).

Post-Conversion Validation

Converting the file format is only half the job. You need to verify that the converted files actually work. Here's a practical validation checklist:

  1. File count check. Count the .xlsx and .xlsm files in your output directory. The total should match your input .xls count. If it doesn't, check your conversion log for failed files.
  2. File size sanity check. Converted .xlsx files should be roughly 20-50% smaller than the originals. If a converted file is significantly larger or is 0 bytes, something went wrong.
  3. Spot-check formulas. Open 5-10 representative files and verify that key calculated cells show the correct values. Pay special attention to files that use VLOOKUP with approximate match, legacy statistical functions (STDEV, RANK, PERCENTILE), or cross-workbook references.
  4. Test macros. For files converted to .xlsm, open them and run key macros. Check that Workbook_Open and Worksheet_Change event handlers fire correctly.
  5. Verify external links. Open files that reference other workbooks and confirm the links resolve. If you converted the referenced files too, the link paths may need updating from .xls to .xlsx.

Common Errors and Fixes

ErrorCauseFix
"Cannot access the file"File is open by another user or processClose the file, or run conversion outside business hours
"The file format differs from the extension".xls file is actually a different format (CSV, HTML) saved with .xls extensionInspect the file manually; rename to correct extension
Macros missing after conversionFile was saved as .xlsx instead of .xlsmRe-convert from the original .xls, saving as .xlsm
"VBA project is locked"The workbook has a password-protected VBA projectYou can still convert; the locked VBA project transfers to .xlsm intact
External links brokenReferenced files were also converted, changing their extensionUpdate link paths from .xls to .xlsx/.xlsm using Edit Links dialog
Script hangs on a fileCorrupt file or Excel waiting for user inputAdd a timeout wrapper; set DisplayAlerts = $false

Ready to migrate?

Download LegacyLeaps and scan your files for free. See exactly what needs to be converted — macros, formula issues, external links — before you spend a penny.

Download Free Scanner

Frequently Asked Questions

Can I bulk convert .xls to .xlsx without opening each file?

Yes. You can use a PowerShell script that automates Excel's COM interface, or a dedicated tool like LegacyLeaps that processes entire folders without manual intervention. Both approaches convert files without requiring you to open each one individually.

Will bulk converting .xls to .xlsx break my macros?

If you blindly convert all files to .xlsx, yes — any VBA macros will be silently stripped. Files containing macros must be saved as .xlsm instead. A proper bulk conversion process detects macros first and routes those files to .xlsm automatically.

How long does it take to bulk convert 1,000 .xls files?

Using a PowerShell script with Excel COM automation, expect roughly 5-15 seconds per file depending on complexity, so 1,000 files takes 1-4 hours. LegacyLeaps processes files faster because it doesn't require a running Excel instance for the initial scan phase.

Related Resources

Get tips like this in your inbox

Practical fixes for legacy Excel and Access problems. No spam.

← Back to all posts