Info: mail-merge demos

Return to index



Sergey Tkachenko

Posted: 03/14/2004 15:16:55

Information about and comparison of 4 TRichView mail merge demos.

2 of them are included in demo projects, other 2 are available as separate



- all fields are text items of some special text style (with the specified


- fields are text items; both initial visible text of these items and tags

of these items are set to field name; but visible text is not important;

tags will be used as field names;

- the template editor does not save collection of styles in template

documents (right-click the template editor's TRichViewEdit, choose

"Settings" in the context menu. You'll see that properties are set to "Use a

predefined set of styles"). So all text formatting in document is defined at

design time, in RVStyle.TextStyles collection

- the template editor's RVStyle and the main application's RVStyle have the

same TextStyles collections but with one exception: the style for fields. In

the template editor's RVStyle, it has a font allowing to see that it is a

field clearly, in the main application's RVStyle it looks like a normal

text. So, then template document is loaded, fields look like a normal text;

- FillFields procedure searches for text item with non-empty tags, and

processes them as fields (changes their visible text)

You can see limitations of this method:

- field value is one line of plain text;

- you cannot define a font of field value text in the template.

This demo can be modified. You can set "Allow adding styles dynamically

mode", and use any text styles for fields (they will be recognized by tags).

You can use their visible text to make them look like fields (for example,

it can be <<Field Name>>) and protection to disallow editing them.


- all fields are text items of some special text style (with the specified

index); but it's easy to modify this demo: fields can be recognized by tags,

or by special properties (protection); this is because the style itself is

not important - field will be deleted at the process of mailmerge;

- this demo does not use tags;

- template editor saves collections of styles in template documents (right

click the template editor's TRichViewEdit, choose "Settings" in the context

menu. You'll see that the properties are set to "Allow adding styles

dynamically"). This allows to add your own styles, implementing commands

like "Bold", "Font", using RichViewActions, etc.

- ReplaceFields deletes fields and inserts field values at their place;

during this process, not only styles of the template are used, but also

styles from documents representing field values.

You can see limitations of this method:

- fields are deleted at the process of mailmerge; if you need to perform

this procedure for the second time, you need to reload template;

But this is the only method allowing to have arbitrary documents as field


Field values are multiline text.

Works absolutely like MailMerge2, but field values are text, not RVF.

Has limitations of both MailMerge and MailMerge2, but simpler than


- fields are not text, but special "label item"; label-items show read-only

one line of text, unwrappable;

- field name is stored in tags; initial text of label-items is not


- you can use "Allow adding styles dynamically" mode with all its bonuses;

- FillFields procedure searches for label items, reads their tags and change

their text; font of "label-items" is not changed, so you can define it in

the template editor.


- field values - one line of text

Read also comments at the beggining of the these demos' main form units.

Powered by ABC Amber Outlook Express Converter