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, you'll build a flow that will loop through all the documents in a OneDrive for Business folder once a day, merge them, and then create a merged Word document in a different location of your choice.

This example combines documents in OneDrive, but you can easily merge multiple files and save them to another destination like Dropbox, Google Drive, SharePoint, or any platform supported by Power Automate.

Prerequisites

Before beginning, ensure the following prerequisites are in place:

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

High-Level Overview

The image below shows a high-level overview of how to merge documents using Power Automate.

merge word documents

Merging MS Word Files Using Power Automate

First create a scheduled cloud flow and then enter a name in the Flow name field. Include the starting date and time, and set it to repeat every day. Press Create.

create power automate flow

Insert the Initialize variable flow action to store the merged contents. Give this action a suitable name, and set the Type field to String. Leave the Value field empty.

store merged contents

Insert the Initialize variable flow action to store the merged count. Set the Type field to Integer and leave the Value field empty.

variable action

Add the OneDrive for Business List files in folder action, and specify the path in the Folder field. This contains all the files that need to be merged.

list files in folder

Insert the Apply to each loop, and add the Output(value) of the List files in folder action.

apply to each loop

Insert the Add a condition action. Specify Is folder?, which is the output of the List files in folder action, and set it to false.

add a condition

If the step above evaluates to true, add the Get file content using path action. In the File Path field, specify the Path variable, which is the output of the List files in folder action.

list files in folder

Insert the Add a condition action. Insert Merged Count, which is the output of Initialize variable – Merged Count, and set it to 0.

add a condition action

If the step above evaluates to true, add the Muhimbi Convert document action.

The action has two parameters:

  • Source file name — The name is the output of the List files in folder action.
  • Source file contentFile content is the output of the Get file content using path action.

get file content

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

The action has three main parameters:

  • Folder Path — This is the path of your destination folder.
  • File Name — You can create a variable for the file name, if needed. This example uses MergeFile.docx.
  • File Content — This is Processed files content, which is the output of the Convert document action.

convert document

If the step above evaluates to false instead of true — i.e. Merged Count isn't equal to 0 — add the Get file content using path action. In the File Path field, specify the Path variable, which is the output of the List files in folder action.

get file content using path

Add the Muhimbi Merge documents action. It has the following parameters:

  • Source files name - 1 — You can hardcode the file name MergeFile.docx. This file name should be the same as in previous steps.
  • Source files content - 1 — The file content is the output of the Get file content using path 2 action from earlier.
  • Source files name - 2 — Enter Name, which is the output of the List files in folder action.
  • Source files content - 2 — Enter Body, which is the output of the Get file content using path action.

source file content

Add the OneDrive for Business Create file 2 action. The action has three main parameters:

  • Folder Path — The path of your destination folder.
  • File Name — This is hardcoded to MergeFile.docx.
  • File Content — This is Processed files content, which is the output of the Merge document action.

merge document action

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

  • Name — Select the Merged Count variable from above.
  • Value — Set the Value field to 1.

You can test this workflow by setting the recurrence frequency to Minute. This will trigger the flow and merge multiple documents in the source folder into a single MS Word document in the target destination.

merged count value

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