Merge Word Documents


The 'Merge Word Documents' flow action merges up to 1000 Microsoft Word documents (DOC, DOCX, DOTX and RTF file formats) provided in a JSON array to a single Microsoft Word document. 

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.

As an array object:

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.

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>"


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

2. Create a new variable which will be utilised to store the files we will later merge

3. Add a 'Get file content' action to retrieve the file. 

3.a Site Address: Set as per the site address from step #1

3.a. File Identifier: Select the 'Identifier' property provided by the 'Get Files (properties only)' action

4. Add an 'Append to array variable' action to add the JSON for the current document to the variable created in step #3.

4.a. Add the following JSON to the Append to array variable' actions 'Value' property:

  "wordInputFormatMode": "keepSourceFormatting"

5.b. Place the cursor as per the image and select the 'File name with extension' property from the SharePoint 'Get Files (properties only)' action.

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

The competed JSON value is as follows:

"fileContent": @{body('Get_file_content')},
"wordInputFormatMode": "keepSourceFormatting"

6. Add the 'Merge Word Documents' action underneath the 'For each' action

6.a. Filename: Enter a value or use dynamic data to construct a filename

6.b. Click the 'Switch to input entire array' icon

6.c. Pass the 'Files' variable created in step #2

7. Add a SharePoint 'Create file' action passing the returned 'Filename' and 'File Content' properties from the 'Merge Word Documents' action.

Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk