Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.5   9.0   9.1   9.2   9.3   9.4   9.5   10.0   10.1   10.2    Statistic  


Replaces a placeholder with text.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
WordFile 5.4 Yes Yes Yes Yes Yes
MBS( "WordFile.ReplaceTag"; WordFile; Placeholder { ; Text; All } )   More


Parameter Description Example value
WordFile The reference number of the open word file. $wordFile
Placeholder The name of the placeholder.

In plugin version 7.4 and newer case insensitive for ASCII characters.
Text Optional
The new text. Should not contain newline characters.
"New York"
All Optional
Pass 1 to replace all placeholders with same text.


Returns OK or error.


Replaces a placeholder with text.
The place holder in the document must start with « and end with » characters. The place holder you pass here, should not have those quotes.
If you need to replace multi line text like addresses, please use several placeholders, at least one per line. Or for newer plugin pass text with new lines, but that will only work for main text and not headers.

If you need to insert multiple entries, you can do this:
Ask the plugin for the XML of the document via WordFile.GetXML. Split the XML into the part before your template line, the template and the xml after. Your line probably is wrapped between a <p> and </p>. Now you can build a new XML with your content and repeat the template part with new text as often as needed. Than pass back the XML to the plugin via WordFile.SetXML.

Version 7.0 and newer can handle multi line text better for normal paragraphs. It creates for you new paragraphs for each line in the new text.

If you change font or style of the text within the marker, it will not be recognized. So please keep all text between and including the « and » markers (or whatever is configured) within the same font style.


Replaces placeholder with text:

Set Variable [$r; Value:MBS("WordFile.ReplaceTag"; $WordFile; "City"; "Nickenich")]

Replaces all placeholder with text:

Set Variable [$r; Value:MBS("WordFile.ReplaceTag"; $WordFile; "City"; "Nickenich"; 1)]

Replace some tags:

# load from container
Set Variable [ $wordfile ; Value: MBS( "WordFile.OpenContainer"; WordFile::Input ) ]
If [ MBS("ISError") ]
    Show Custom Dialog [ "Error" ; $wordFile ]
    Exit Current Script [ Result: ]
End If
# replace placeholders from one record
Set Variable [ $r ; Value: MBS( "WordFile.ReplaceTag"; $WordFile; "FG_Nr"; WordFile::FG_Nr.) ]
Set Variable [ $r ; Value: MBS( "WordFile.ReplaceTag"; $WordFile; "P_Name"; WordFile::P_Name) ]
Set Variable [ $r ; Value: MBS( "WordFile.ReplaceTag"; $WordFile; "P_Vorname"; WordFile::P_Vorname) ]
# write to desktop
Set Variable [ $DesktopPath ; Value: MBS("Folders.UserDesktop") ]
Set Variable [ $FilePath ; Value: MBS( "Path.AddPathComponent"; $DesktopPath; "test output.docx" ) ]
Set Variable [ $r ; Value: MBS( "WordFile.WriteFile"; $WordFile; $FilePath ) ]
Set Variable [ $r ; Value: MBS( "Files.LaunchFile"; $FilePath ) ]
# clean up
Set Variable [ $r ; Value: MBS("WordFile.Release"; $WordFile) ]

See also

Example Databases

Blog Entries

FileMaker Magazin

  • Ausgabe 6/2016, Seite 39

Release notes

  • Version 9.4
    • Fixed a bug in WordFile.ReplaceTag where it would not update the modified XML correctly for replace in header section.
  • Version 9.2
  • Version 7.4
  • Version 7.2
  • Version 7.0
    • Changed WordFile.ReplaceTag to create multiple paragraphs if text to replace contains multiple lines and is part of a normal text paragraph.

Created 5th November 2015, last changed 6th September 2019

WordFile.RemoveTableRow   -   WordFile.SetCaseless

Feedback: Report problem or ask question.

MBS Xojo PDF Plugins