Creating mail merge templates in MS Word 2010

ckrause

Well-known member
Joined
Oct 9, 2009
Messages
87
Programming Experience
5-10
One of the main advantages of TX Text Control's mail merge approach is that you can use templates created in MS Word. Even if TX Text Control comes with the TX Template Designer, MS Word might be deeply entrenched in your business processes.

The following tutorial shows how to insert the various supported merge elements like merge fields, repeating blocks or a date field into a template. At the end of this tutorial, we will have created a template that is mergeable using the MailMerge component that comes with TX Text Control .NET Server for Windows Forms and WPF.

The goal is to create a simple invoice template with dynamic fields for the recipient, the date and the articles that will be repeated in a separate repeating block.

1. Start with creating a new document in MS Word and add some static content like a header with your own address:

step1.png


2. As a next step, click the Insert Date and Time button in the Text ribbon group, part of the Insert tab page.

step2.png


In the opened dialog, select a format and confirm with OK.

step2b.png


After inserting the static content and the date field, the document should look like this:

step2c.png


3. Now, we want to add the recipient's name and address details to the invoice. In the same Text ribbon group, open the Quick Parts drop-down button and select Field... in order to open the Field dialog box.

step3.png


Filter the field category by Mail Merge and select MergeField as the field type name. Type in a Field name and confirm with OK.

step3b.png


Repeat this step until you added all required address fields to the template. The following screenshot shows how it should look like:

step3c.png


4. A table must be created to list the variable number of items in the invoice. From the Insert ribbon tab page, insert a 4x4 table using the insertion wizard.

step4.png


The first row is the table header and contains the column titles. Set the input position into a cell of the first row and click Repeat Header Rows from the Table Tools - Layout tab page:

step4a.png


Then insert merge fields into the second row as described in step 3. The document should now look like this:

step4b.png


5. As a final step, we need to define the repeating block in the template. The repeating block is defined by a bookmark at the start position and one at the end position of the block. Therefore, set the input position to the very beginning of the second table row - in front of the merge field «article_code» and click on Bookmark from the Insert - Links ribbon menu.

step5.png


In the opened Bookmark dialog box, add the start bookmark with the name blockstart_items - whereas blockstart_ is the indicator that this bookmark is the start of a block and items is the name of the block.

step5b.png


Repeat this step for the bookmark at the end of the repeating block and name it blockend_items. The two bookmarks should look like in the following screenshot:

step5c.png


To show the bookmarks in MS Word, please open the Word Options, select Advanced and check Show bookmarks from the Show document content subsection.


About TX Text Control:

TX Text Control was originally released in 1991, since then more than 40,000 copies have been sold. Starting off as a single, small DLL, TX Text Control has made its way through 16-bit DLL and VBX versions to today‘s Enterprise edition with its .NET and ActiveX components. The recent addition to the family, TX Text Control .NET Server, offers all of TX Text Control advanced word processing functionality in an easy-to-use server-side .NET component. Customers benefit from these years of experience, large user base, and at the same time, appreciate developing with a mature, reliable product.

Contact Informations:

support@textcontrol.com

North & South America:
Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)

Europe:
Phone: +49 (0)421 42 70 67 10

Asia Pacific:
Phone: +886 2-2797-8508
 
Back
Top