Header Disappears After SaveAs in IronWord
When you populate a DOCX template with IronWord and write the result with SaveAs(), the template's header can vanish from the generated file. The placeholders merge correctly, but the header present in the source document does not survive the save.
Header (e.g. "City Attorney Cover Sheet") is visible in the original DOCX
but missing in the generated file after calling SaveAs().

The header is preserved when you write the document with Save() rather than SaveAs(). This was confirmed on IronWord 2026.2.1, a .NET 8 console application running on Windows 11 Enterprise x64 (24H2).
Solution
1. Load the Template
Open the source DOCX with WordDocument.
using IronWord;
using System.Collections.Generic;
var templatePath = @"C:\Templates\CityAttorneyCoverSheetTemplate.docx";
var outputPath = @"C:\Output\merged.docx";
var doc = new WordDocument(templatePath);
using IronWord;
using System.Collections.Generic;
var templatePath = @"C:\Templates\CityAttorneyCoverSheetTemplate.docx";
var outputPath = @"C:\Output\merged.docx";
var doc = new WordDocument(templatePath);
Imports IronWord
Imports System.Collections.Generic
Dim templatePath As String = "C:\Templates\CityAttorneyCoverSheetTemplate.docx"
Dim outputPath As String = "C:\Output\merged.docx"
Dim doc As New WordDocument(templatePath)
2. Replace the Placeholders
Merge your values through doc.Texts, which is the recommended approach for template replacement.
var replacements = new Dictionary<string, string>
{
["{CaseNumber}"] = "2026-CR-12345",
["{DefendantName}"] = "John Doe",
["{DefendantAge}"] = "34",
["{DefendantAttorney}"] = "Jane Smith",
};
foreach (var kv in replacements)
{
doc.Texts.ForEach(t => t.Replace(kv.Key, kv.Value));
}
var replacements = new Dictionary<string, string>
{
["{CaseNumber}"] = "2026-CR-12345",
["{DefendantName}"] = "John Doe",
["{DefendantAge}"] = "34",
["{DefendantAttorney}"] = "Jane Smith",
};
foreach (var kv in replacements)
{
doc.Texts.ForEach(t => t.Replace(kv.Key, kv.Value));
}
Imports System.Collections.Generic
Dim replacements As New Dictionary(Of String, String) From {
{"{CaseNumber}", "2026-CR-12345"},
{"{DefendantName}", "John Doe"},
{"{DefendantAge}", "34"},
{"{DefendantAttorney}", "Jane Smith"}
}
For Each kv In replacements
doc.Texts.ForEach(Sub(t) t.Replace(kv.Key, kv.Value))
Next
Iterating each entry over doc.Texts swaps every placeholder token for its merge value across the document body.
3. Save With Save(), Not SaveAs()
Write the output with doc.Save(outputPath). This keeps the header intact, where doc.SaveAs(outputPath) may drop it.
doc.Save(outputPath);
doc.Save(outputPath);
doc.Save(outputPath)

Notes
- If your workflow requires
SaveAs(): verify on the latest IronWord version whether the header survives in your environment. - If the issue reappears: pin to a previously working version as a short-term mitigation while the behavior is investigated.

