Excel Format Guide

XLSB to XLSM Converter: Preserve Macros When Switching Formats (2026)

Sponsored

Updated April 2026 · By MacroKit Team · 8 min read

XLSB is Excel's highest-performance format. Financial modelers, data analysts, and anyone working with spreadsheets over 50,000 rows tends to end up there eventually — file sizes drop by 50-70%, and open/save times improve dramatically. The catch is portability: XLSB is an Excel-only format that non-Microsoft tools handle poorly or not at all.

When you need to share a macro-enabled workbook with someone who uses LibreOffice, a web-based Excel viewer, or a Python pipeline, XLSM is the correct output. This guide covers what XLSB actually is, when switching to XLSM makes sense, and how to convert without losing a single VBA module.

What Is XLSB and Why Does It Exist?

XLSB stands for Excel Binary Workbook. It was introduced alongside the Open XML formats in Excel 2007, not as a replacement for XLSM, but as a performance-optimized alternative for large, complex workbooks that don't need to be editable by non-Excel tools.

The "binary" in XLSB refers to the cell data format. While XLSM stores worksheet data as XML (e.g., <c r="A1" t="n"><v>42</v></c>), XLSB stores the same cell as a compact binary record — a few bytes instead of dozens of characters. This is the BIFF12 format: a new binary record specification that Microsoft designed specifically for Office 2007+ performance.

Despite the different data layer, XLSB still stores VBA in exactly the same way as XLSM: as a vbaProject.bin COM Structured Storage binary. Both formats are ZIP archives at the top level. The difference is only in how worksheet data is serialized inside that ZIP.

Here's a simplified view of both archives:

# XLSM structure (simplified)
macro_workbook.xlsm (ZIP)
├── [Content_Types].xml
├── xl/
│   ├── workbook.xml         ← XML
│   ├── worksheets/sheet1.xml ← XML (cell data)
│   ├── vbaProject.bin       ← Binary (VBA)
│   └── styles.xml           ← XML

# XLSB structure (simplified)
macro_workbook.xlsb (ZIP)
├── [Content_Types].xml
├── xl/
│   ├── workbook.bin         ← Binary (BIFF12)
│   ├── worksheets/sheet1.bin ← Binary (cell data)
│   ├── vbaProject.bin       ← Binary (VBA) — IDENTICAL
│   └── styles.bin           ← Binary

Notice that vbaProject.bin is present in both and is structurally identical. This is why XLSB to XLSM conversion, done correctly, is conceptually straightforward: convert the binary worksheet data to XML, and carry the VBA blob through unchanged.

When Should You Switch from XLSB to XLSM?

XLSB is the right format when Excel is the only tool that will ever touch the file and performance is a priority. Switch to XLSM when any of the following apply:

The Conversion: Excel Save As

The most reliable XLSB to XLSM conversion is Excel's own Save As. Because both formats share the same vbaProject.bin structure, Excel simply rewrites the worksheet data as XML and copies the VBA blob verbatim.

  1. Open the XLSB file in Excel.
  2. Press Alt + F11 and note the module list in the Project Explorer. Count modules and class modules.
  3. Go to File → Save As.
  4. Select Excel Macro-Enabled Workbook (*.xlsm) from the format dropdown.
  5. Save to a new filename. Do not overwrite the original.
  6. Close and reopen the XLSM. Verify VBA modules via Alt + F11.
  7. Run each macro to confirm runtime behavior.

Stop losing macros on every conversion

The Macro-Safe Converter Kit gives you the exact workflow, tested scripts, and decision checklist to convert without losing a single line of VBA.

Get the Kit — $9

One-time · Instant download · 30-day guarantee

Python Approach: pyxlsb + openpyxl

Python has no single library that can read an XLSB with VBA and write it as XLSM. You need two libraries working in sequence:

import zipfile
from pathlib import Path
from pyxlsb import open_workbook
import openpyxl

def xlsb_to_xlsm(src: str, dst: str):
    src_path = Path(src)
    dst_path = Path(dst)

    # Step 1: Extract vbaProject.bin from XLSB
    vba_blob = None
    with zipfile.ZipFile(src_path, 'r') as z:
        if 'xl/vbaProject.bin' in z.namelist():
            vba_blob = z.read('xl/vbaProject.bin')
        else:
            print("WARNING: No vbaProject.bin found in source XLSB")

    # Step 2: Read cell data from XLSB
    wb_out = openpyxl.Workbook()
    wb_out.remove(wb_out.active)  # Remove default empty sheet

    with open_workbook(src_path) as wb_in:
        for sheet_name in wb_in.sheets:
            ws_out = wb_out.create_sheet(title=sheet_name)
            with wb_in.get_sheet(sheet_name) as ws_in:
                for row in ws_in.rows():
                    for cell in row:
                        if cell.v is not None:
                            ws_out.cell(
                                row=cell.r, column=cell.c, value=cell.v
                            )

    # Step 3: Save initial XLSM (no VBA yet)
    temp_path = dst_path.with_suffix('.tmp.xlsm')
    wb_out.save(temp_path)

    # Step 4: Inject vbaProject.bin into the XLSM ZIP
    if vba_blob:
        with zipfile.ZipFile(temp_path, 'a') as z:
            z.writestr('xl/vbaProject.bin', vba_blob)
        # Note: Content_Types.xml also needs updating for full compliance
        # For production use, Excel Save As is still more reliable
        print(f"VBA injected ({len(vba_blob):,} bytes)")

    temp_path.rename(dst_path)
    print(f"Saved: {dst_path}")

xlsb_to_xlsm("source.xlsb", "output.xlsm")
Important: The Python approach above has a limitation — manually injecting vbaProject.bin into a ZIP without updating [Content_Types].xml to declare the correct MIME type may cause Excel to ignore it. For a production-quality conversion, you also need to patch the content types XML. The script above is suitable for validating the VBA preservation concept; the Excel Save As method is more reliable for actual deployment.

File Size Trade-off Table

Workbook Type XLSB Size XLSM Size Size Increase
Small model (5K rows, 20 cols) 280 KB 420 KB ~50%
Medium dataset (100K rows) 8.2 MB 22 MB ~168%
Large financial model (500K rows) 41 MB 118 MB ~188%
VBA-heavy, small data (50 modules) 1.1 MB 1.3 MB ~18%

The file size increase scales with data volume, not with macro complexity. The vbaProject.bin is the same size in both formats — it's the worksheet data serialization that differs. For VBA-heavy workbooks with relatively little data, the conversion penalty is negligible.

LibreOffice CLI Conversion

LibreOffice can convert XLSB to XLSM from the command line, though XLSB reading support is less mature than its XLS or XLSX support:

# Single file
libreoffice --headless --convert-to xlsm yourfile.xlsb

# Check LibreOffice version first (7.4+ has better XLSB support)
libreoffice --version

If LibreOffice misreads the XLSB (producing garbled data or blank sheets), fall back to the Excel Save As method. XLSB is Microsoft's format with no public specification, and third-party implementations rely on reverse engineering — they work for the common cases but can fail on complex files with pivot tables, Power Query connections, or unusual number formats.

Keeping XLSB for Active Work, XLSM for Distribution

A practical strategy for teams that need both performance and portability: maintain a master XLSB for daily use, and generate an XLSM distribution copy when needed. A small VBA macro inside the XLSB itself can automate this:

Sub ExportAsXLSM()
    Dim srcPath As String
    Dim dstPath As String
    srcPath = ThisWorkbook.FullName
    dstPath = Replace(srcPath, ".xlsb", "_dist.xlsm")
    ThisWorkbook.SaveAs Filename:=dstPath, _
        FileFormat:=xlOpenXMLWorkbookMacroEnabled
    ' Reopen the original XLSB
    Workbooks.Open srcPath
    MsgBox "XLSM saved: " & dstPath
End Sub

Run this macro whenever you need to produce a shareable copy. The XLSB remains the working file; the XLSM is a distribution artifact.

Summary: XLSB and XLSM both store VBA as an identical vbaProject.bin binary. Converting between them is technically clean — Excel's Save As is the most reliable tool, LibreOffice works for straightforward files, and Python requires a two-library approach. The main cost of switching from XLSB to XLSM is file size and load time, which matters for large datasets but is negligible for most macro-heavy workbooks.

Frequently Asked Questions

Why is XLSB smaller and faster than XLSM?

XLSB stores cell data in a binary format (BIFF12) rather than XML. XML is text — every number is stored as its ASCII string representation, every cell tag adds dozens of characters of markup overhead. XLSB skips the XML layer entirely, storing data as compact binary records. For spreadsheets with hundreds of thousands of rows, this can mean 60-70% smaller files and 3-5x faster open/save times.

Do XLSB files support VBA macros?

Yes. XLSB is the binary equivalent of XLSM — it supports all the same VBA capabilities. The vbaProject.bin blob is embedded in the XLSB file alongside the binary worksheet data. This is why converting XLSB to XLSM, done correctly, simply extracts that same blob and places it in the new ZIP-based container.

Will converting XLSB to XLSM affect performance?

Yes, for large workbooks. XLSM stores cell data as XML, which is larger and slower to parse than XLSB's binary records. A 200MB XLSB might become 400-600MB as XLSM, and open/save times will increase proportionally. For files under 10MB the difference is negligible. For larger financial models or data files, keep XLSB for active use and only convert when you need cross-platform portability.

Related Guides

Best Macro-Safe Excel Converter Tools 2026Tool comparison guide Excel Macro Migration Guide 2026Complete migration walkthrough Convert XLS to XLSX Without Losing MacrosStep-by-step guide

Stop losing macros on every conversion

The Macro-Safe Converter Kit gives you the exact workflow, tested scripts, and decision checklist to convert without losing a single line of VBA.

Get the Kit — $9

One-time · Instant download · 30-day guarantee