Create Merge Fields

[Top]  [Chapter]  [Previous]  [Next]

There are several ways to create a merge fields in a document:

 

a) Use the API to create a field:

 

To insert a field use the method InputField. It expects the name of the field and the initial text. The boolean parameter controls if the cursor should be placed inside (true) or after the new field (false). Using the true you can insert multiple paragraphs or an image inside of the field.

 

VB:

TextCursor.InputField "NAME", "Name-Field", False

 

C#:

TextCursor.InputField("NAME","Name-Field",false);

 

b) Load RTF code which contains fields:

 

TextDynamic uses standard RTF tags to load and save fields so merge fields inserted in Word are usually available in TextDynamic as well (without the extended attributes).

 

c) Load RTF text which contains tokens and let the tokens convert into fields:

 

You can inserted the tags using escape text, i.e. <name> and use either

- the method IWPTextCursor.FieldsFromTokens(StartText,EndText,FieldPreText) (=ReplaceTokens)

- or TextCommandStr(17) "Token To Template Conversion". The latter can ignore start codes which are used inside the text.

 

You can use TextCommandStr(16) activate syntax highlighting to display the tokens as bold red text.

 

 

Note: Fields are displayed as « and ». Memo.ShowFields = true to display field names instead and WPDLLInt1.SpecialTextAttr(SpecialTextSel.wpInsertpoints).Hidden = true to hide fields.

 

 

Note: It is possible to delete certain fields with Memo.TextCommandStr.

 

It is now also possible to the the Memo.Save and Load methods to read and write the data of a certain field. Please see Load and Save Category -  Formatstrings.

 

 


[createmergefields.htm]    Copyright © 2007 by WPCubed GmbH