Setting up Table Mail Merge

Table mail merges can be used to populate a table in a Microsoft Word document with data from a data source. The data source can come from a SQL database, an Excel spreadsheet, or another location where your data is stored.

Example: You have a data source that contains the item number, description, quantity, price, and total price of ten different items. You want to put that information into a Word document. That word document already contains a template of the headers "Item No.," "Description," "Qty," "Unit Price," and "Total Price," as in the image below. Use the Update Word Document activity to populate that template with the data in the data source into the corresponding headers.

Note: If you just want to put the data into the Word document and do not care if it goes into a table, use a simple field merge as in the Bill To area in the image above.

To setup a table mail merge

  1. Select the Update Word Document activity, and in the Properties Pane, select New under Modifications.
  2. In the New Modification dialog box, select Table Field Merge from the Type drop-down menu.

  3. Under Source Data File, click the Select link. Choose Results from the Query Data or Custom Query activity that performs the database lookup for the values you want to insert into the Word table.
  4. Next to Merge Region Name, insert the name of the region that corresponds to the Word table. This region is the name you included in your Word table along with the TableStart and TableEnd fields. For example, in the image at the top, the table uses the name "MyTable" in <<TableStart:MyTable>> and <<TableEnd:MyTable>> to indicate the name of the table. This is also the name you must include in Merge Region Name.
  5. Note: You must mark the beginning of a row of the table with "TableStart" along with a name that corresponds to the title of the table that you will use for Merge Region Name. You must also mark the end of the same row of the table with "TableEnd" along with the same name. If you do not include the TableStart and TableEnd fields, it is treated as a simple merge.

  6. While you can manually input the names of the merge field columns from your Word table, it is more efficient to click the Import field names from document link below the table. Clicking this list automatically populates the table with all the merge fields Workflow can interact with. If Workflow doesn't find any merge fields, then it will prompt you to import other types of fields from the document. If you click Yes at this prompt, any items in the document that are wrapped in double curly brackets {{ }} will be returned.
  7. In the Value column, choose a value from the drop-down. The field will be replaced with this value when the workflow runs.
  8. In the Type column, choose the type of data that will be entered into the field. Setting the type is important if you are inserting a token whose value could be one of multiple types (e.g., it could be interpreted as a string or a number), and you want to ensure Word interprets the token correctly. In most cases, leaving Default in this column is sufficient.
  9. In the Options column, click Default to provide custom formatting for the field. You have the option to use the default formatting, render the field as a checkbox, or render it as a barcode. You can also define custom properties for barcodes not listed in the Barcode Type drop-down menu by writing "TYPE=barcode_format", where you replace the word barcode_format with a barcode property. Use the drop-down below for a list of barcode-property options.
  10. To add more fields to the table in the New Modification dialog box, start typing in the last row. To delete a field, click the gray space to the left of the field's row and press the Delete key.
  11. Below the table of fields are several options for cleaning up the Word document after the merge runs. Select the checkbox next to
    • Remove empty paragraphs to remove empty paragraphs created by the merge.
    • Remove unused fields to remove fields that weren't specified in the merge.
    • Remove unused regions to remove regions that weren't specified in the merge.
    • Remove containing fields to remove fields that contain other fields.
    • Remove static fields to remove fields that remain the same upon any document changes.
    • Clear mail merge settings to remove existing mail merge settings.
    • Replace non merge fields to merge other types of fields.
    • Merge duplicate regions to merge multiple duplicate table fields.
  12. Click OK.