Mailmerge and forms

Top  Previous  Next

The mail merge feature is exceptionally strong with WPTools. You can merge in standard ANSI text, formatted text and images. Formatted text may be encoded in HTML, RTF or the WPTOOLS format.

 

The merge fields always use a start and an end marker:

clip0081

 

The markers use internally the TWPTextObj class. The start marker stores the name of the field in the 'name' property. The ObjType property of both, the start and the end marker is both set to wpobjMergeField.

 

The display of the markers is optional, it can be disabled by setting property WPRichText.InsertPointTextAttr.Hidden to true. It is also possible to show a different text in a different color.

 

Example:

WPRichText1.InsertPointAttr.CodeOpeningText := '[%N=';

// %N inserts the TWPTextObj.Name property

// %S inserts the TWPTextObj.Source property

// %Y inserts the TWPTextObj.StyleName property - only useful for span styles

// %P inserts the TWPTextObj.Params property

WPRichText1.InsertPointAttr.CodeClosingText := ']';

WPRichText1.InsertPointAttr.CodeTextColor := clBlue;

 

This is how the field is displayed now:

clip0082

 

WPRichText.InsertPointTextAttr.Hidden should be set to true when the document is printed. To delete the fields (and keep the text) use the procedure.DeleteFields.

 

Hint: Please check out the ThreadSave demo to learn how to use mail merge in a thread.