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: 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
50 4B 03 04The ZIP signature
The same as XLSX, XLSM and XLTX. Only the content type inside tells them apart.
- 2
ContentType="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
<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
_xlnm.Print_AreaThe print area
A built-in defined name that limits printing to the invoice itself.
- 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
<f>B9*C9</f><v>0</v>A formula with its result
The amount for each line. The template stores
0as the cached result, and a number format hides zeros, so empty lines stay blank. - 7
<dataValidationData 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 XLTM | Word, from a DOTM | |
|---|---|---|
| Macros in the new file | Copied into the new workbook | Not copied; they stay in the template |
| Saving the new file | Needs a macro-enabled format such as XLSM to keep them; saving as XLSX drops them | Saved as DOCX by default |
| If the template is deleted later | The workbooks still have their macros | The 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.xltxtemplate 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
| Format | What it is | Macros |
|---|---|---|
| XLTM | Excel template, ZIP of XML | Allowed; copied into new workbooks |
| XLTX | Excel template, ZIP of XML | Not allowed |
| XLT | Excel 97-2003 template, binary | Allowed, and the name doesn't tell you |
| XLSM | Workbook with macros | Allowed; opens as itself |
| XLAM | Excel add-in | Allowed; 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.xltmlists 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=Trueand keepwb.template = Trueto save one back as a macro-enabled template; withoutkeep_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.
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.
Placeholders to fill in
Invoice number, date and customer, with grey italic text on a pale yellow fill.
Ten line items
Description, quantity and unit price are yours to fill; the amount is
=B9*C9and so on. A number format hides the zeros on empty lines.Totals with a named rate
Subtotal with
SUM, VAT withROUND(D20*VATRate,2)and a total.VATRatepoints to 21% on the Settings sheet; change it there.Data validation
Quantities accept whole numbers of 0 or more, with an error message otherwise.
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.xlsxon 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.xltmin Excel. You should get a new, unsaved workbook, not the template file. - Detection: a detector that reads
[Content_Types].xmlshould 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=Truethe output has the XLTX content type, so saving it under.xltmcreates 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.xltmis 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
- Microsoft Learn: XML file name extension reference for Office
- Microsoft [MS-OFFMACRO2]: Office Macro-Enabled File Format Version 2
- Microsoft Support: Copy your macros to a Personal Macro Workbook
- Microsoft Learn: Macros from the internet are blocked by default in Office
- MITRE ATT&CK: Office Template Macros (T1137.001)
- Library of Congress: OOXML format family
Last reviewed 27 October 2026.