File types · Explainer

The XLTM file (.xltm)

An XLTM file is an Excel template that is allowed to contain macros: opening it creates a new workbook with the template's sheets, formulas and any macros it holds. This guide explains what new workbooks inherit, how it differs from XLTX and XLSM, where Excel's startup files fit in, and has free sample XLTM files, without macros, to download for testing.

At a glance

Full name
Excel Macro-Enabled Template
Extensions
.xltm
MIME type
application/vnd.ms-excel.template.macroEnabled.12
Kind
Binary: a ZIP package of XML parts (SpreadsheetML), plus an optional binary VBA project
Standard
Office Open XML (ECMA-376, ISO/IEC 29500); Microsoft's [MS-OFFMACRO2] for the macro parts
First released
2007, with Excel 2007, by Microsoft
Opens with
Microsoft Excel (opening creates a new workbook), LibreOffice Calc
Magic number
50 4B 03 04 ("PK"), the ZIP signature
Workbook content type
application/vnd.ms-excel.template.macroEnabled.main+xml
Macros
VBA and Excel 4.0 (XLM) macro sheets, both optional; new workbooks inherit them

The basics

What is an XLTM file?

An XLTM is an Excel template with macros allowed. Like an XLTX, it's a starting point: opening it doesn't open the file itself but creates a new, unsaved workbook with the template's sheets, formulas, formatting and settings. The difference is that an XLTM can also carry VBA code and Excel 4.0 macro sheets.

Typical uses are forms and reports that come with their own automation: an invoice that numbers itself, a timesheet with a button that exports the week, or a report that pulls in data when you create it.

Our samples contain no macros

Each XLTM on this page is the macro-enabled template package without a VBA project or macro sheet, safe to open. olevba reports "No VBA or XLM macros found".

Anatomy

What's inside an XLTM file

An XLTM is built like an XLSX: XML parts in a ZIP archive. This is sample-invoice-template.xltm from the samples below, an invoice template with formulas and no macros. With macros, it would also hold xl/vbaProject.bin, as the XLSM page shows.

sample-invoice-template.xltm (structure)
sample-invoice-template.xltm: unzip -l, dates left out
     1092  [Content_Types].xml
      531  _rels/.rels
      205  docProps/app.xml
     1093  docProps/core.xml
    10140  xl/theme/theme1.xml
     3840  xl/worksheets/sheet1.xml     sheet "Invoice"
      768  xl/worksheets/sheet2.xml     sheet "Settings"
     4681  xl/styles.xml
      847  xl/workbook.xml
      649  xl/_rels/workbook.xml.rels

First 4 bytes: 50 4B 03 04  (PK..)

In [Content_Types].xml:
<Override PartName="/xl/workbook.xml"
  ContentType="application/vnd.ms-excel.template.macroEnabled.main+xml"/>

In xl/workbook.xml:
<definedNames>
  <definedName name="VATRate">Settings!$B$1</definedName>
  <definedName name="_xlnm.Print_Area" localSheetId="0">'Invoice'!$A$1:$D$24</definedName>
</definedNames>

In xl/worksheets/sheet1.xml (Invoice):
<c r="B4" s="4" t="inlineStr"><is><t>[Invoice number]</t></is></c>
<c r="D9" s="9"><f>B9*C9</f><v>0</v></c>
<c r="D21" s="11"><f>ROUND(D20*VATRate,2)</f><v>0</v></c>
<dataValidation sqref="B9:B18" … type="whole" operator="greaterThanOrEqual">
  <formula1>0</formula1></dataValidation>
  1. 150 4B 03 04

    The ZIP signature

    The same as XLSX, XLSM and XLTX. Only the content type inside tells them apart.

  2. 2ContentType="application/vnd.ms-excel.template.macroEnabled.main+xml"

    The template content type

    Says two things: this is a template, so opening it creates a new workbook, and it's macro-enabled. An XLTX has …spreadsheetml.template.main+xml, an XLSM …sheet.macroEnabled.main+xml.

  3. 3<definedName name="VATRate">

    A defined name

    The VAT rate lives on the Settings sheet, and formulas refer to it by name. Every invoice made from the template gets the name too.

  4. 4_xlnm.Print_Area

    The print area

    A built-in defined name that limits printing to the invoice itself.

  5. 5[Invoice number]

    A placeholder

    Text the user types over. Excel has no placeholder feature like Word's content controls, so templates use text and a fill colour.

  6. 6<f>B9*C9</f><v>0</v>

    A formula with its result

    The amount for each line. The template stores 0 as the cached result, and a number format hides zeros, so empty lines stay blank.

  7. 7<dataValidation

    Data validation

    Quantities must be whole numbers of 0 or more. Rules like this travel into every new workbook.

Inheritance

New workbooks inherit the template's macros

Microsoft's file format reference says it plainly: workbooks created from an XLTM inherit its VBA project and Excel 4.0 macro sheets. The code is copied into each new workbook. Word does the opposite: documents made from a DOTM stay linked to the template and don't get a copy of its macros.

Excel, from an XLTMWord, from a DOTM
Macros in the new fileCopied into the new workbookNot copied; they stay in the template
Saving the new fileNeeds a macro-enabled format such as XLSM to keep them; saving as XLSX drops themSaved as DOCX by default
If the template is deleted laterThe workbooks still have their macrosThe documents lose access to them

So every workbook made from a macro-enabled template is itself a file with code in it. When you send one on, the recipient's Excel treats it like any XLSM.

Startup files

XLSTART, Personal.xlsb and add-ins

Templates aren't the only way to make macros available across workbooks. Excel has three other places, which are worth knowing when you're looking for where some code comes from:

  • The XLSTART folder. Workbooks in it open automatically whenever Excel starts. It's also where a Book.xltx template for new blank workbooks goes; the XLTX page explains that.
  • Personal.xlsb, the Personal Macro Workbook. Choose it under "Store macro in" when you record a macro, and Excel saves it in XLSTART so the macro is available in every workbook on that computer. It's a binary XLSB workbook, not a template.
  • Add-ins (.xlam), loaded under File, Options, Add-ins. Their code runs alongside every workbook while they're loaded.

Because they load silently with Excel, XLSTART and the personal macro workbook are also used by attackers to keep malicious code running (MITRE ATT&CK T1137.001). If Excel opens unexpected workbooks or runs code at startup, look there first.

Comparison

XLTM vs XLTX, XLT, XLSM and XLAM

FormatWhat it isMacros
XLTMExcel template, ZIP of XMLAllowed; copied into new workbooks
XLTXExcel template, ZIP of XMLNot allowed
XLTExcel 97-2003 template, binaryAllowed, and the name doesn't tell you
XLSMWorkbook with macrosAllowed; opens as itself
XLAMExcel add-inAllowed; code shared with all open workbooks

Choose XLTX unless the template needs code: workbooks made from it will then be plain XLSX files, which open without macro warnings and pass mail filters.

Security

Is an XLTM file safe?

  • Mark of the Web. Microsoft's 2022 change to block macros in files from the internet names Excel templates (.xlt, .xltm) and add-ins (.xla, .xlam) explicitly. On Windows, a downloaded XLTM with macros opens with a red Security Risk banner and the macros blocked.
  • The new workbook carries the code. Even if you only meant to use the template once, the workbook you saved from it holds the same macros.
  • Check before you use it. olevba template.xltm lists VBA modules and Excel 4.0 macros without running them. The XLSM page has more on inspecting workbooks.

How to

How to open, edit and convert an XLTM file

  • Use it: double-click it, or put it in your personal templates folder and choose File, New, Personal in Excel. You get a new workbook based on it.
  • Edit the template itself: in Excel, File, Open and pick the .xltm, then save it again as Excel Macro-Enabled Template.
  • Remove the macros: File, Save As, Excel Template (.xltx). The VBA project is left out.
  • LibreOffice Calc opens XLTM files and can run some Excel VBA, under its own macro security settings.
  • In code: openpyxl opens XLTM files. Load with keep_vba=True and keep wb.template = True to save one back as a macro-enabled template; without keep_vba, it writes the XLTX content type.

Free downloads

Sample XLTM files to download

Free sample Excel macro-enabled templates for testing upload filters, template flows and spreadsheet libraries. None of them contains macros: each is a valid XLTM package without a VBA project, safe to open. All were checked with unzip -t, openpyxl (keep_vba=True, which reports template=True), a LibreOffice conversion to PDF and olevba.

sample-invoice-template.xltm · 6.6 KBDownload

Browsers can't show this kind of file in a page. Download it to open it in the app it belongs to.

What's inside sample-invoice-template.xltm

Browsers can't preview an XLTM. Double-click it in Excel to get a new invoice workbook, or open it from inside Excel to see the template.

  1. Placeholders to fill in

    Invoice number, date and customer, with grey italic text on a pale yellow fill.

  2. Ten line items

    Description, quantity and unit price are yours to fill; the amount is =B9*C9 and so on. A number format hides the zeros on empty lines.

  3. Totals with a named rate

    Subtotal with SUM, VAT with ROUND(D20*VATRate,2) and a total. VATRate points to 21% on the Settings sheet; change it there.

  4. Data validation

    Quantities accept whole numbers of 0 or more, with an error message otherwise.

  5. Print area and properties

    A print area around the invoice, and document properties saying the template contains no macros.

All sample XLTM files

  • Invoice template (no macros)

    sample-invoice-template.xltm · 6.6 KB (6,773 bytes)

    An invoice template for the fictional Example Studio: placeholders, ten line items with formulas, subtotal, VAT from a defined name, total, data validation and a print area. Made with openpyxl and given the macro-enabled template content type.

    • Testing "new from template" flows
    • Checking how libraries read templates
  • Minimal XLTM (5 parts)

    sample-minimal.xltm · 1.6 KB (1,651 bytes)

    Written by hand: content types, two relationship files, the workbook and one sheet, like sample-minimal.xlsx on the XLSX page but with the macro-enabled template content type.

    • Parser tests against the bare minimum
    • Comparing XLSX, XLSM and XLTM content types
  • 100 KB XLTM file

    sample-100kb.xltm · 100 KB (102,400 bytes)

    The invoice template, padded to exactly 102,400 bytes with whitespace inside docProps/app.xml, stored uncompressed. No macros.

    • Upload and size-limit tests
    • Type-based filter tests

Ways to test with them

  • New from template: double-click sample-invoice-template.xltm in Excel. You should get a new, unsaved workbook, not the template file.
  • Detection: a detector that reads [Content_Types].xml should report an Excel macro-enabled template for all three files. One that reports XLSX or XLSM is ignoring part of the content type.
  • Library round trip: load a sample in openpyxl and save it. Without keep_vba=True the output has the XLTX content type, so saving it under .xltm creates a file Excel won't open.
  • Formulas: after entering a quantity of 2 and a price of 10 on the first line, the total should read €24.20 with the 21% rate.
  • Size limits: sample-100kb.xltm is exactly 102,400 bytes.

Free to use for testing, teaching and demos, commercially or not, with no attribution needed. A link back to this page is always appreciated.

Put it online

Have an XLTM file? Give it a link.

Drop an Excel macro-enabled template on 99helpers and it gets its own link. Visitors download it and open it in Excel; if it has macros, Excel on Windows blocks them because the file came from the internet.

Questions

XLTM files, frequently asked

What is an XLTM file?

An Excel template that can contain macros. Opening it creates a new workbook with the template's sheets, formulas, formatting and macros.

What's the difference between XLTX and XLTM?

An XLTM can contain VBA and Excel 4.0 macros, and passes them on to new workbooks. An XLTX can't contain macros. Otherwise they're the same format.

What's the difference between XLSM and XLTM?

An XLSM is a workbook you open and save directly. An XLTM is a template: opening it gives you a new copy to fill in, and the template stays unchanged.

Do workbooks created from an XLTM contain its macros?

Yes. Excel copies the VBA project and any Excel 4.0 macro sheets into each new workbook, so save them as XLSM if you want to keep the macros.

How do I edit an XLTM template?

Open Excel first, then File, Open and choose the template. Double-clicking it creates a new workbook instead of opening the template.

Is an XLTM file safe to open?

Only if you trust the source, because it can contain macros that end up in every workbook you create from it. Office on Windows blocks macros in templates downloaded from the internet.

Is Personal.xlsb a template?

No. It's a hidden personal macro workbook in Excel's XLSTART folder, in the binary XLSB format, that makes your recorded macros available in every workbook.

Related formats

Other file types explained

Keep going

Related

Sources

Last reviewed 27 October 2026.