Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides
New in version: 6.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3    Statistic  

WordFile.ReplaceTag

Replaces a placeholder with text.

Component: WordFile
Version: 5.4
Mac OS X: Yes
Windows: Yes
Server: Yes
FileMaker Cloud: Yes

MBS( "WordFile.ReplaceTag"; WordFile; Placeholder { ; Text; All } )

Parameters

Parameter Description Example value
WordFile The reference number of the open word file. $wordFile
Placeholder The name of the placeholder. "City"
Text Optional
The new text. Should not contain newline characters.
"New York"
All Optional
Pass 1 to replace all placeholders with same text.
1

Result

Returns OK or error.

Description

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.

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.

Examples

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
Variable setzen [ $wordfile ; Wert: MBS( "WordFile.OpenContainer"; WordFile::Input ) ]
Wenn [ MBS("ISError") ]
    Eigenes Dialogfeld anzeigen [ "Error" ; $wordFile ]
    Aktuelles Script verlassen [ Textergebnis: ]
Ende (wenn)
# replace placeholders from one record
Variable setzen [ $r ; Wert: MBS( "WordFile.ReplaceTag"; $WordFile; "FG_Nr"; WordFile::FG_Nr.) ]
Variable setzen [ $r ; Wert: MBS( "WordFile.ReplaceTag"; $WordFile; "P_Name"; WordFile::P_Name) ]
Variable setzen [ $r ; Wert: MBS( "WordFile.ReplaceTag"; $WordFile; "P_Vorname"; WordFile::P_Vorname) ]
# write to desktop
Variable setzen [ $DesktopPath ; Wert: MBS("Folders.UserDesktop") ]
Variable setzen [ $FilePath ; Wert: MBS( "Path.AddPathComponent"; $DesktopPath; "test output.docx" ) ]
Variable setzen [ $r ; Wert: MBS( "WordFile.WriteFile"; $WordFile; $FilePath ) ]
Variable setzen [ $r ; Wert: MBS( "Files.LaunchFile"; $FilePath ) ]
# clean up
Variable setzen [ $r ; Wert: MBS("WordFile.Release"; $WordFile) ]

See also

Example Databases


WordFile.RemoveTableRow   -   WordFile.SetMarkers

Feedback: Report problem or ask question.




Links
MBS FileMaker Plugins