# MailMerge.LoadTemplate Method

> Loads a template from a file that is used for the merge process.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 14.0
- **Namespace:** `TXTextControl.DocumentServer`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXDocumentServer.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXDocumentServer.dll` from the setup
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl.DocumentServer > MailMerge.LoadTemplate Method
- **496 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/loadtemplate-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/loadtemplate-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/loadtemplate-method/llms-full.txt

---

### Description

Loads a template from a file that is used for the merge process.

### Syntax

```csharp
public bool LoadTemplate(string filename, FileFormat documentFormat);
```

```vbnet
Public Function LoadTemplate(filename As String, documentFormat As FileFormat) As Boolean
```

### Parameters

| Parameter | Description |
|---|---|
| filename | Specifies a template file from which the data is loaded. |
| documentFormat | Specifies one of the DocumentServer.FileFormat values. |

### Return Value

Returns true, if the template could be loaded successfully and false, if the template is invalid or could not be loaded properly.

### Examples

The following example uses Load Template in a focused Mail Merge workflow.

```csharp
if (mailMerge.LoadTemplate("document.docx", TXTextControl.DocumentServer.FileFormat.MSWord))
{
    Console.WriteLine("Load Template completed successfully.");
}
```

```vbnet
If mailMerge.LoadTemplate("document.docx", TXTextControl.DocumentServer.FileFormat.MSWord) Then
    Console.WriteLine("Load Template completed successfully.")
End If
```

---

## Nearby

- **Previous:** [MailMerge.IncludeTextMergingEventArgs.IncludeTextField Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge-includetextmergingeventargs/includetextfield-property/llms-full.txt)
- **Next:** [MailMerge.LoadTemplateFromMemory Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/loadtemplatefrommemory-method/llms-full.txt)
