# MailMerge.SaveDocument Method

> Saves the merged document to a file.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 14.0
- **Namespace:** `TXTextControl.DocumentServer`
- **Package:** `TXTextControl.TextControl.WinForms.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 Windows Forms > Reference > TXTextControl.DocumentServer > MailMerge.SaveDocument Method
- **511 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/savedocument-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/savedocument-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/savedocument-method/llms-full.txt

---

### Description

Saves the merged document to a file.

### Syntax

```csharp
public void SaveDocument(string fileName, StreamType fileFormat, SaveSettings saveSettings);
```

```vbnet
Public Sub SaveDocument(fileName As String, fileFormat As StreamType, saveSettings As SaveSettings)
```

### Parameters

| Parameter | Description |
|---|---|
| fileName | Specifies a file into which the data is saved. If the file does not exist, it is created. If the file exists, its contents are overwritten. |
| fileFormat | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/streamtype/enumeration/llms-full.txt) values. |
| saveSettings | Specifies a [SaveSettings](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/llms-full.txt) object with additional information and settings for the save operation. |

### Examples

The following example uses Save Document in a focused Mail Merge workflow. The created object is then available to the surrounding document workflow.

```csharp
mailMerge.SaveDocument("document.docx", StreamType.WordprocessingML, new SaveSettings());
Console.WriteLine("Mail Merge is ready for use.");
```

```vbnet
mailMerge.SaveDocument("document.docx", StreamType.WordprocessingML, New SaveSettings())
Console.WriteLine("Mail Merge is ready for use.")
```

---

## Nearby

- **Previous:** [MailMerge.ReportDataSourceConfigFile Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/reportdatasourceconfigfile-property/llms-full.txt)
- **Next:** [MailMerge.SaveDocumentToMemory Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/mailmerge/savedocumenttomemory-method/llms-full.txt)
