8.3 - Creating and using a document template
This section describes how to create document templates and to use them in moveon for personalised documents such as letters, certificates, student contracts, payment slips, etc., for one or more recipients.
1- Principle
The document templates used in moveon are MS Word mail merge documents. An MS Word mail merge document is a document associated with a data source containing the data for one or more recipients (in moveon this is an MS Excel file containing the moveon data). This document includes merge fields associated with data source fields (in moveon these fields include the name and address of the recipient, the name of the institution, etc.). When the mail merge document is merged, a document is created for each recipient. The merge fields are automatically personalised for the recipient using the data from the data source.
The mail merge documents are created with MS Word and then listed in moveon as document templates. In moveon you can then use the Document button in various forms to open one of the listed document templates for one or more recipients. When you open the document, moveon automatically creates an MS Excel file containing the data for the selected recipients, opens the document template and automatically configures the MS Excel file as the data source for the mail merge document. The merge fields then need to be added to the document. If the document template has been used before, the data for the recipient(s) is displayed automatically when the document template is opened in MS Word.
You can use the mail merge functions in a similar way to create envelopes, labels or personalised e-mail messages. In the first step of the MS Word Mail Merge wizard, simply select the type of document you require and follow the prompts.
2- Creating a new document template
To create a new document template and use it directly from moveon you must carry out the following steps:
- Create an MS Word document
- List this document as a document template in moveon
- Open the document template from moveon by clicking the Document button
- Insert the merge fields into the document template
Step 1 - Create an MS Word document
Start by creating a document in MS Word, either by creating and formatting a new document or by using an existing document. Do not use the mail merge functions at this stage. Once your document is ready, save it as a .doc file and close the document.
To help you find these documents in moveon and to make them available to all moveon users, we recommend that you save all these documents in a shared folder on a file server accessible to all users, for example under M:/documents, where M:/ is the shared folder reserved for moveon. The document folder can itself be divided into different sub-folders corresponding to the various recipient types (outgoing students, external contacts, etc.).
Step 2 - List the document as a document template in moveon
Once you have created the MS Word document, you need to list it in moveon as a document template in the document template configuration form.
To open this form, click in the main menu on "Configuration", and then on "Document templates".
To add a document template, click the Add button. This opens the window for adding document templates
For each document template you can specify the following data (fields marked with an asterisk are mandatory):
- Recipients (*) (select from a drop-down list)
- Name of the document template in moveon (*) (no restriction)
- Access path for the MS Word file (*) (select by clicking the Select file button)
Step 3 - Open the document template from moveon
Before you can add the merge fields to the document template you need to open the document template from moveon so that moveon can automatically generate the MS Excel file containing the recipient data and configure it as the data source for the document template.
Paragraph 3 of this section describes in detail how to open a document template from moveon. To do so, use the Document button in the data form or selection form corresponding to the type of recipients of the document template created. Any recipient can be selected for this operation.
When the document is opened, the MS Excel file is configured automatically as the data source for the document template. The Mail Merge toolbar should appear at the top of the screen. If it does not, you can activate it by selecting Toolbars, then Mail Merge in the Display menu.
Step 4 - Insert the merge fields in the document template
Now you need to insert the merge fields in the mail merge document. Position the cursor in the appropriate place and click Insert Merge Fields in the Mail Merge toolbar. A list appears, from which you can select the moveon field to insert. Once you have selected and confirmed the field, it is inserted at the desired position. Repeat this operation until you have inserted all the fields you require. Section 10.1 provides a full list of the data fields in moveon.
The «»ABC button is used to match the names of the merge fields to the data in the data source. In this way you can view the document with the actual moveon data.
Save the document and then write-protect it to prevent the format or contents from being changed when the document is used. To activate write protection, tick the "Read only" box in the file properties.
3- Opening a document template from moveon
Document templates can be used for creating and printing a personalised document for a single recipient (using data forms) or for multiple recipients (using selection forms).
Using document templates for a single recipient
To open a document template for a single recipient, open the data form corresponding to the type of recipient you require. Then click the Document button to open the document template selection window. Select the document template you require from the list of documents available for this type of recipient. Then click the Document button to open the document in MS Word.
Example: Document template for an external contactOpen the "Institutions" form, select an institution and then on the "Contacts" tab click the Document button corresponding to one of the contacts displayed.
Select the document template you require and then click the Document button to open the document in MS Word.
Using document templates for multiple recipients
If you wish to edit a single document template for multiple recipients, use the selection form corresponding to the type of recipient you require. Use the selection criteria to select the recipients of the document template. Then click Next to open the "Actions" form.
On the "Correspondence" tab of the "Actions" form select the document you require from the list of documents available for this type of recipient. Then click the Document button to open the document in MS Word.
Example: Document template for multiple external contacts
Open the "Select external contacts" form from the main menu by clicking "Institutions", "Select external contacts". Select the external contacts you require and then click Next.
On the "Correspondence" tab of the "Actions" form select the document template you require and then click Document to open the document in MS Word.
4- Using the Mail Merge toolbar in MS Word
This paragraph describes the main functions of the Mail Merge toolbar.
«»ABC button: This button is used for matching the names of the merge fields to the actual moveon data.
"Insert Word Field" button: This button gives you access to various advanced functions. For example, the If...Then...Else function allows you to insert a formulation appropriate to the gender of the recipient, for example the greeting line in a letter. This function enables you to check whether the content of the gender field for the recipient is M (male) and to define two values (e.g. Mr or Ms) depending on the result.
Navigation buttons: If you have selected more than one recipient, these buttons can be used to navigate between them.
"Merge to New Document" button: This button allows you to save the results of the mail merge to a new document. This document is now no longer linked to the database. This operation does not alter the document template and allows you to personalise each letter to the individual recipient.
"Merge to Printer" button: This button is used for printing the document template for all recipients. The standard Print button only prints the document for the recipient shown.
5- Configuring the save path for the MS Excel files (optional)
If the MS Excel file is not saved automatically at your institution, you can specify in the configuration of moveon the access path to a local or personal directory, in which the MS Excel files will be stored. This parameter is configured in the "Document templates" frame of the "General settings" form (see chapter 2.1). This directory should be the same for all moveon users and must be created on each workstation (e.g.: C:/Program Files/moveon/xls/).
If the MS Excel files are saved automatically, you can leave this field blank.
6- Formatting merge fields
In mail merge documents, when you use fields containing numbers, financial data or dates, you can change the format using switches. This section describes how to edit the code of a merge field and gives examples of the use of these switches.
Changing the format of merge fields with MS Word XP/2003
Open the document template that you wish to edit. If necessary, click on the «»ABC button in the Mail Merge toolbar to go from the data view to the merge fields view. Right-click on the merge field whose format you wish to change, then click in the context menu on the "Toggle Field Codes" option. The merge field code is displayed. Insert a space between the name of the merge field and the brace (}) which closes the code, and then enter the format of the field beginning with a switch (\@, \#, etc.), using the following examples for reference. Click on "Toggle Field Codes" again. The field code is now hidden again. Then click on the «»ABC button in the Mail Merge toolbar to display the view with the data from the data source.
Appearance in the Mail Merge view before the format is changed:
2004/12/25
Appearance of the field when the field code is not displayed:
« mobilities#mobility_startdate »
Appearance of the field when the field code is displayed:
{Mergefield mobilities#mobility_startdate}
Appearance of the field when the desired switch has been inserted:
{Mergefield mobilities#mobility_startdate \@ "dd/MM/yyyy" }
Appearance in the Mail Merge view after the format is changed:
25/12/2004
Note: Depending on which country is selected in MS Windows, different symbols and formats are used for number fields, financial data and dates. If you are unsure about which symbol or format is used in the selected country, you can check in MS Windows under: Start – Control Panel – Regional and Language Options.
Examples of merge field formats
Number fields
« 3 » : { Mergefield grantsgrant_duration}
« 03 » : { Mergefield grantsgrant_duration \# "00"}
« 6.50 » : { Mergefield grantsgrant_duration \# "0.00"}
« 6,5 » : { Mergefield grantsgrant_duration \# "0,0"}
Financial data
« EUR 1.234,50 » : { Mergefield entriesentry_amount \# "EUR ###.##0,00" }
« 1.234,50 » : { Mergefield entriesentry_amount \# "###.##0,00" }
You can also vary the format depending on whether the amount is positive, negative or zero.
{ Mergefield entriesentry_amount \# "0,00;-0,00;''" }
The text of the switch between quotation marks then consists of 3 parts. The first and second parts correspond to the format for a positive and negative value respectively, and the third part consists of two quotation marks only (delete the zero when the amount is zero).
Dates
The replacement characters are d for day, y for year, M for month. The correct case must be used, since a lower-case m corresponds to a minute. The way in which the month or day of the week appears depends on the regional and language settings on your computer. You can change them in the Control Panel of MS Windows (see above).
« 25/12/2004 » : { Mergefield mobilitiesmobility_startdate \@ "dd/MM/yyyy" }
« 25.12.2004 » : { Mergefield mobilitiesmobility_startdate \@ "dd.MM.yyyy" }
« 2004-12-25 » : { Mergefield mobilitiesmobility_startdate \@ "yyyy-MM-dd" }
"25 Dec. 2004": { Mergefield mobilitiesmobility_startdate \@ "d MMM. yyyy" }
"25 December 2004": { Mergefield mobilitiesmobility_startdate \@ "d MMMM yyyy" }
"December": { Mergefield mobilitiesmobility_startdate \@ "MMMM" }
"Saturday": { Mergefield mobilitiesmobility_startdate \@ "dddd" }
Bug in MS Word XP: Confusion between day and month in merge fields
Unfortunately MS Word XP returns incorrect results for fields containing a date. In these fields, the day and month are inverted if you have selected a shortened display of the date in the Control Panel of MS Windows (e.g. d.m.yyyy) and the day of the date is less than or equal to 12. The date is correct when the day is greater than 12 and wrong in other cases.
This problem is corrected in Service Pack 3 of MS Office XP. To resolve the problem, you must therefore install (or have installed) the latest Service Pack of Microsoft Office XP on your computer.
Modified: 2010-11-18 00:18:54