Update Word Document
This activity performs a series of modifications on a Microsoft Word document.
To set up this activity:
- Drag the activity from the toolbox pane and drop it in the Designer pane.
- In the properties pane, type a name and description of the activity.
- In the Document to Modify property box, select the Word document you want to modify from the following options:
- Server attachment: Select an electronic document attached in Files. Click the Browse button (ellipsis) to browse to an attachment.
- Activity: Attach a document created by an activity in your workflow. To attach a document:
- Click the Edit button to select an entry from an activity earlier in your workflow definition.
- Hover over the activity you want to select the source from.
- Select a source in the activity.
- In the Modifications property box, click New....
- Select a type of modification: Find Replace, Simple Field Merge, or Table Field Merge and configure the options for that type of modification.Find Replace
Automate Word's find and replace functionality. Your document does not have to contain merge fields or any special formatting for this option to work.
Example: The Acme Insurance Company has a new client information packet they like to customize with the client's and the account manager's name. When a new client is brought in, their name and their account manager's name are added to the metadata on the Client's folder. Once those two fields are filled out, a workflow starts that runs an Update Word Document activity. This activity automatically looks for ClientName and AccountManagerName in each document in the folder and replaces those values with the client and account manager's actual names.
To configure Find Replace:
- Click New....
- In the New Modification dialog box, ensure Find Replace is selected in the Type drop-down.
- Next to Find what, type the characters you want workflow to find in the document. Click the right arrow to add a token.
- Next to Replace with, type the characters workflow will replace the found values with. Click the right arrow to add a token.
- If you select the Case sensitive option, the activity will only find results with the same capitalization pattern as the value you type next to Find what. Clear this option to find matches regardless of capitalization.
- If you select the Match whole word option, the activity will only find whole words, not partial words. For example, if you select this option and configure the activity to find the word book, it will find all instances of the word book but not bookmark or booking.
- If you select the Use regular expressions option, you can use regular expressions to extract specific information from a token you've added to your Find value. For example, if you put an address token in the Find what field, you can use regular expressions to only find the zip code from the address. Learn more about regular expressions
- Click OK to confirm your changes.
Note: The Find Replace option is designed for short text fragments or single word replacements, and does not support paragraphs of multiple lines of text. For this, use the Simple Field Merge option.
Simple Field MergeIf you have a document that is going to be updated by a database as well as a workflow, or if you have more complicated updating needs, select the Simple Field Merge option. To configure Simple Field Merge:
- Select New....
- In the New Modification dialog box, ensure Simple Field Merge is selected in the Type drop-down.
- You can populate the table automatically or manually.
To populate the table automatically:
- Select Import Fields….
- Select one of the following options:
- Use attached workflow file: Select a document attached in Files.
- Select a file: Choose a file on your local machine.
- Click OK.
To populate the table manually:
- Select Add Field to add a merge field.
- Type the name of the field under Field Name.
- Type the value that the field will be replaced with when the workflow runs under Value. Click the right arrow to add a token.
- Select the type of data for the field under Type. Setting the type is important if you are inserting a token with a value that could be one of multiple types. In most cases, leaving Default in this column is sufficient.
- Select the Default link to provide custom formatting for the field, including default formatting, checkbox fields, or barcodes.
Note: You can define custom properties for barcodes not listed in the Barcode Type drop-down menu.
- Below the table of fields are several options for cleaning up the Word document after the merge runs. You can remove empty paragraphs, fields, regions, containing fields, and static fields. You can also clear mail merge settings configured in the Mail Merge wizard. Select the Replace non merge fields option if you have other types of fields in your document (e.g., text wrapped in double curly brackets {{}}) that you want this activity to replace.
Table Field MergePopulate a Word document's table using a data source. If you select this option you must have a Run Rule activity that retrieves the data you want to insert into the table from a lookup table or other data source earlier in your workflow.
To configure Table Field Merge:
- Select New....
- In the New Modification dialog box, ensure Table Field Merge is selected in the Type drop-down.
- Next to Activity, click the Edit button to specify the values you want to insert into the Word table.
- Next to Merge Region Name, type the name of the region that corresponds to the table in Word. The region is the value you specified after the "TableStart" and "TableEnd" fields in your table.
- After you select the file in step 3, populate the table with all the merge fields. You can do this manually by selecting Add Field and typing the name of the field in the text boxes under Field Name manually or selecting Import field names from document below the table to populate the table automatically.
- In the Value column, select a token. The field will be replaced with the token's value when the workflow runs.
- In the Type column, select 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, for example, it could be interpreted as a string or number, and you want to ensure Word interprets the token correctly. In most cases, leaving Default in this column is sufficient.
- 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 define custom properties for barcodes not listed in the Barcode Type drop-down menu.
- To add a field to the table in the New Modification dialog box, click the Add Field link below the table. To remove a field from the table, click the Remove link in the field's row.
- Below the table of fields are several options for cleaning up the Word document after the merge runs. You can remove empty paragraphs, fields, regions, containing fields, and static fields. You can also clear mail merge settings configured in the Mail Merge wizard. Select the Replace non merge fields option if you have other types of fields in your document (e.g., text wrapped in double curly brackets {{}}) that you want this activity to replace.
- Click OK.
- In the Output Document Options property box, select additional actions on the document.
- Create new document: Creates a new document with the changes made by the activity instead of updating the existing document.
- Convert to PDF: Converts the resulting document to PDF format.
- Rename Document: Changes the name of the document to the value you provide here.
- Overwrite Source Documents (activity sourced files only): Overwrites the source document when you select Activity in the drop-down menu in the Document to Modify property box.
- Emit email token: Creates a token containing the resulting content.
- Report serialization warnings: Displays warnings from serialization in the Messages tab in the instance report.
- Create new document: Creates a new document with the changes made by the activity instead of updating the existing document.
You may want to disable activities if you only want to test specific sections of your workflow. To disable activities:
- Select an activity in the designer pane to highlight it.
- In the Description property box, clear Enable.
For an example that uses this feature across process automation, see the Migrating Laserfiche Form Tables into Microsoft Word Documents whitepaper.