|[Top] [Chapter] [Previous] [Next]|
"Mail merge" makes it possible to update fields which were embedded in the text with external data. Due to it versatility it is one of the most popular features offered by TextDynamic.
This is the name field: «NAME»
After first call to MergeText() we read:
This is the name field: «Julian Ziersch»
After second call to MergeText() we read:
This is the name field: «WPCubed GmbH»
(The field markers « and » can be made invisible.)
To use the mail merge feature you only need to
a) insert fields
b) create callback which fills in data
c) start the merge process
You can use Memo.MergeText each time the data which should be inserted has been updated. So it is easy to create a viewing form for database records. The previous contents of the field will be updated. The field is not destroyed by the merge process, such as it is in the usual search&replace approach.
With TextDynamic you can also read out the text inside of a field when the event OnFieldGetText is triggered. So you can also create a database input form.
If you want to do mass mailing you can execute MergeText and append the merged text to a different, internal text buffer. Please see our create list and label printing demo which show how to use this powerful feature.
Please see the example for InputCell if you need to dynamically create a table with inserted merge fields.
Like hyperlinks merge fields use paired objects. One object marks the start of the field, the other the end. The text within is the "embedded text". You can customize the component to show or hide the fieldmarkers (SpecialTextAttr(wpInsertpoints).Hidden). It is also possible to display a single object only which shows the name of the field. (property IWPMemo.ShowFields)