WordFile.WriteFile
------------------

Writes a file to disk.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [WordFile](component_WordFile.md) | [5.4](newinversion54.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "WordFile.WriteFile"; WordFile; Path ) 

**MBS**( **"WordFile.WriteFile";** /\* Writes a file to disk. \*/  
**$WordFile**; /\* The reference number of the open word file. \*/   
**$Path**) /\* The native file path.e.g. "C:\\Test\\test.docx" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| WordFile | The reference number of the open word file. | $wordFile |
| Path | The native file path. | "C:\\Test\\test.docx" |

### Result

Returns OK or error.

### Description

Writes a file to disk.  
File extension should be correct, either docx or xml depending on what you loaded.  
May break if newer versions of Microsoft Word or Office change the docx file format.  
  
See [FileDialog](component_FileDialog.md) functions if you like to show a save dialog to pick a destination for the file path.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Writes a DocX file:

 Set Variable \[$r ; Value:MBS ("WordFile.WriteFile"; $WordFile ; "/Users/cs/Desktop/TestOutput.docx")\]  
### See also

- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [WordFile.AppendTableRow](WordFileAppendTableRow.md)
- [WordFile.OpenFile](WordFileOpenFile.md)
- [WordFile.ReplaceTag](WordFileReplaceTag.md)
- [WordFile.SetMediaFile](WordFileSetMediaFile.md)
- [ZipFile.WriteFile](ZipFileWriteFile.md)

### Example Databases

- [WordFile/WordFile](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WordFile/WordFile.shtml#1ScriptAnchor_)

### Blog Entries

- [New in MBS FileMaker Plugin 11.4](https://www.mbsplugins.de/archive/2021-09-15/New_in_MBS_FileMaker_Plugin_11/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2021, Seite 20 bis 21](https://filemaker-magazin.de/neuigkeit/4165-Appetithappen-FMM_202106)
- [Ausgabe 6/2016, Seite 39](https://filemaker-magazin.de/neuigkeit/3913-Appetithappen-FMM_201606)

This function checks for a license.

Created 5th November 2015 , last changed 22nd December 2022

  
[WordFile.WriteContainer](WordFileWriteContainer.md) - [X509.Description](X509Description.md)

[HTML Version](WordFileWriteFile.shtml)