Merge Word Documents

Overview

The 'Merge Word Documents' flow action merges up to 1000 Microsoft Word documents provided in a JSON array to a single Microsoft Word document. 

Please refer to the Supported Document Types articles for a complete list of the different file formats/document types which are supported for conversion.

Example Flow

Please refer to the following article showcasing the 'Merge Word Documents' flow action: Build a proposal document dynamically using SharePoint and Flow

Power Automate Templates

Default Parameters

The default 'Merge Word Documents' flow action parameters are detailed below:

  • Filename: The filename to assign to the resulting Microsoft Word document (including the file extension).
  • Documents: An array of Microsoft Word documents and associated configuration

As a manually entered array:

  • Filename: The filename of the source Microsoft Word document (including the file extension).
  • File Content: A Base64 encoded representation of the Microsoft Word document
  • Sort Position: Set the sort position for the document within the array, the lowest number first.
  • Format Mode: Select how to handle merging Microsoft Word document styles.
    • KeepSourceFormatting: To maintain the current document's styles
    • KeepDifferentStyles: Allows styles to be reused if they are identical to the styles within the source document. If styles are different to the destination then they are imported.
    • UseDestinationStyles: Re-uses styles within the destination document.

mceclip3.png

As an array object:

mceclip0.png

Advanced Parameters

The advanced 'Merge Word Documents' flow action parameters are detailed below:

  • Time Zone: Set a specific time zone for date and time processing.

mceclip2.png

Microsoft Word Format Support

The following Microsoft Word document types are supported:

  • docx
  • doc
  • dotx

Documents - JSON Schema 

The JSON provided within the documents parameter should conform to the following schema:

{
"fileName": "<Filename including extension>",
"fileContent": "<File contents (Base 64 string)>",
"sortPosition": <Optional - Sort position number>,
"wordInputFormatMode": "<Optional - Formatting type>"
}

Troubleshooting

Please review the following article if you experience an issue executing the 'Merge document array to PDF' action: Errors processing Document Arrays

Creating the JSON Array

Flow provides the actions required to build the JSON array which is required by the 'Documents' parameter. The following example shows how to retrieve documents from a SharePoint folder and dynamically build the array.

1. Configure the 'Get Files (properties only)' action to retrieve a list of target files

mceclip2.png

2. Optional - Configure the 'Limit Entries to Folder' property to target documents contained within a specific SharePoint folder.

mceclip1.png

3. Create a new variable which will be utilised to store the JSON which we will later provide to the 'Documents' parameter of the 'Merge document array to Word' action.

mceclip2.png

4. Add an 'Apply to Each' action, selecting the 'value' variable returned from the 'Get files (properties only)' action.

5. Inside the 'Apply to Each' action; Add a 'Get file properties' action to retrieve the file's properties, passing the ID of the current item:

mceclip4.png

6. Inside the 'Apply to Each' action; Add a 'Get file content' action to retrieve the file. Select the 'Identifier' field from the 'Get file properties' action.

mceclip5.png

The action configuration should be as follows:

mceclip6.png

7. Inside the 'Apply to Each' action;

7a. Add an 'Append to array variable' action to append JSON data to the variable created in Step 3. Copy and paste this JSON snippet into the 'Value' field:

{
  "fileName":,
  "fileContent":,
  "wordInputFormatMode": "keepSourceFormatting"
}

 mceclip0.png

7b. Place the cursor as per the image and select the 'File name with extension' property from the SharePoint 'Get files properties' action.

mceclip7.png

7c. Place the cursor as per the image and select the 'File Content' property from the SharePoint 'Get file content' action.

 

mceclip8.png

7f. Once copied the action configuration should be as follows:

mceclip9.png

8. Underneath the 'Apply to Each' action; Add the 'Merge Word Documents' action.

8a. Provide a 'Filename' value, then click the 'Switch to input entire array' icon

mceclip15.png

8b. Select and delete any existing data within the 'Documents' field:

mceclip16.png

8c. Select the 'Document Array' variable created in step #3

mceclip17.png

9. Add a SharePoint 'Create file' action and set the 'Site Address' and 'Folder Path' fields as required.

9a. File Name: Select the 'Filename' field from the 'Merge Word Documents' action.

mceclip19.png

9b. File Content: Select the 'File Content' field from the 'Merge Word Documents' action.

mceclip20.png

10. The completed flow should look as follows, noting you may have a different trigger action:

mceclip10.png

11. Execute the Flow to merge the targeted Microsoft Word documents into a single Microsoft Word document.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk