Merge MS Word files using Power Automate

In this guide you’ll learn how to combine and merge multiple Word files into a single Word document using Power Automate.

For this specific example we build a Flow that will Loop through all the documents once a day in a OneDrive for Business Folder, merge them, and then create a merged Word document in a different location of our choice.

It’s important to note that in this example we are combining documents in OneDrive but you can easily merge multiple documents and save them to another destination like Dropbox, Google Drive, SharePoint, or any platform supported by Power Automate.

Prerequisites

Before we begin please make sure the following prerequisites are in place:

  • An Office 365 subscription with Flow and OneDrive for Business support.
  • Muhimbi PDF Converter for Power Automate full or free trial subscription.
  • Appropriate privileges to create Flows.
  • Working knowledge of Microsoft Flow.

Merging MS Word using Power Automate (Flow Array Technique)

From a high level, the Flow will look like this:

merge word documents

  1. Create a Scheduled Cloud Flow and then enter a suitable Flow Name, with a suitable Start Date and Start Time with a recurrence set to every day.

    create power automate flow

  2. Insert ‘Initialize variable’ Flow action to store the Merged Contents. Give this action a suitable name and set the fields as follows:
    Type: ‘String’
    Initial value: *Null

    store merged contents

  3. Insert ‘Initialize variable’ Flow action to store the Merged Count.

Type: “Integer”

Initial Value: Null

variable action

  1. Add the OneDrive for Business ‘List Files in folder’ Action on the Folder library which contains all the files that need to be Merged.

    list files in folder

  2. Insert the ‘Apply to Each Loop’ and add the Output(value) of ‘List Files in folder’ action.

apply to each loop

  1. Insert the ‘Add a condition’ action. Insert IsFolder is the Output of “List Files in folder” and you need to set it to “False”.

    add a condition

  2. If the step above, evaluates to True, add the action ‘Get file content using path’

File Path: Path variable which is the output of ‘List Files in folder’.

list files in folder

  1. Insert the ‘Add a condition’ action. Insert Merge Count is the Output of ‘Initialize variable – Merge Count’ and you need to set it to “0”.

    add a condition action

  2. If the step above, evaluates to True, add the Muhimbi ‘Convert Document Action’

The Action has two parameters:

Source File Name: ‘Name’ is the output of ‘List Files in folder’.

**Source File Content: *‘***Body’ is the output of ‘Get file Content using Path’.

get file content

  1. Insert the OneDrive for Business ‘Create file’ action after the ‘Convert document’ action.

The action has three main parameters

Folder Path: The Path of your destination Folder.

File name: You can create a variable for File name if needed. We have hardcoded it to ‘MergedFile.docx’.

File Content: Processed File Content is the output of ‘Convert Document’ action.

convert document

  1. Now, if the step 8 above, evaluates to False i.e. Merge Count is now not equal to 0, then add the action ‘Get file Content using Path’.

File Path : Enter the same path as in step 10.

get file content using path

  1. Add the Muhimbi ‘Merge documents’ action. It has the following two main parameters

    Source File name -1: You can hardcode the File Name ‘MergedFile.docx’ This file name should be the same as in step 10 and 11.

Source File Content -1: File Content is the output of ‘Get file Content using Path 2’ as in step 11.

Source File name -2: Name is the output of ‘List Files in folder’.

Source File Content -2: File Content is the output of ‘Get file Content using Path’ in step 8.

source file content

  1. Add the OneDrive for Business ‘Create file’ action, under step 12. The Action has three main parameters:

Folder Path: The path of your destination folder.

File name: We have hardcoded it to ‘MergedFile.docx’.

File Content: Processed File Content is the output of ‘Merge Document’ action.

merge document action

  1. Outside ‘Condition 2’ action, add a ‘Set variable’ action. The action has two main parameters:

Name: Select the ‘Merged Count’ variable initialized in step 2.

Value: Set the Value to 1.

merged count value

You can test this workflow by setting the recurrence “Recurrence” Frequency to ‘Minute’. This will trigger the Flow after a minute and merge multiple documents in the source folder to a single MS Word document in the target location.

Additional Resources

Have a Question?
We’re Always Happy to Help.

© Muhimbi Ltd. 2008 - 2024
This website uses cookies to ensure you get the best experience. Learn more