Merge Word Documents


The 'Merge Word Documents' flow action merges up to 10 Microsoft Word documents provided in an 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

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, smallest number first.
  • Format Mode: Select how to handle merging Microsoft Word document styles.
    • KeepSourceFormatting: To maintain the current documents 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:


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

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. Utilise the 'Get Files (properties only)' action to retrieve a list of target files


2. (Optionally) Filter the list of target files returned by the action 'Get Files (properties only)' action. The example below filters the data to only items which originate from the 'Merge Array' folder.


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.


4. Add an 'Apply to Each' action, selecting the 'Body' variable returned from the 'Filter Array' action. This will enable the processing of each item from the filtered array created in step #2


5. Inside the 'Apply to Each' action; Add a 'Get file properties' action to retrieve the files properties, passing the ID of the current item by copying and pasting the following expression into the 'Id' field:



Once copied the action configuration should be as follows:


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.


Once copied the action configuration should be as follows:


7. Inside the 'Apply to Each' action; Add an 'Append to array variable' action to append JSON data to the variable created in Step 3. Copy and past this JSON snippet into the 'Value' field :

  "fileContent": @{body('Get_file_content')?['$content']},
  "wordInputFormatMode": "keepSourceFormatting"



Once copied the action configuration should be as follows:


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


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


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


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

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


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


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


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

Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk