Merge Word Documents in Power Automate
What this action does
PDF4me, Merge Documents combines multiple Word files (DOCX/DOC) into a single merged document inside your Power Automate flow. Control the merge order with SortPosition, choose how styles are handled (KeepSourceFormatting, UseDestinationStyles, KeepDifferentStyles), and set the OOXML compliance level. Pull documents from SharePoint, OneDrive, Dropbox, or email, the output is a clean, single DOCX ready for distribution or further processing.
Authenticating Your API Request
Every PDF4me action in Power Automate requires a valid connection. Enter your PDF4me API key when you add the action for the first time, it is reused automatically in all subsequent PDF4me actions in the same flow.
Important Facts You Should Not Miss

Build the Documents array with one entry per file. Map DocContent from a Get File Content step, not a URL. SortPosition 0 is the base document; all others append in order.
Parameters
Required: Documents array with at least one entry. Each entry requires Filename, DocContent (file binary), and SortPosition. FormatMode and Merge Options are optional.
| Parameter | Required | What it does | Example |
|---|---|---|---|
| Documents | Yes | Array of document objects to merge. Each object requires Filename, DocContent, and SortPosition. The array must contain at least one entry. Documents merge in ascending SortPosition order. | [{Filename, DocContent, SortPosition}] |
| Documents[].Filename | Yes | Filename of the document including extension. Must be .docx or .doc. Used for format detection and document identification during merge. | chapter1.docx |
| Documents[].DocContent | Yes | Raw binary content of the Word file. Map from the output body of a SharePoint Get File Content or OneDrive Get File Content action. Do not pass a URL, path, or filename string here. | File Content body |
| Documents[].SortPosition | Yes | Integer determining merge order. The document with the lowest SortPosition becomes the base document. All others are appended in ascending order. Use any integers: 0, 1, 2 or 10, 20, 30 are both valid. | 0 |
| Documents[].FormatMode | No | How styles are handled for this document during merge. Options: KeepSourceFormatting (default: preserves document's own styles), UseDestinationStyles (adopts base document styles), KeepDifferentStyles (retains distinct styles only). | UseDestinationStyles |
| Merge Options Time Zone | No | Timezone identifier added to the merged document metadata. Use standard identifiers like UTC, Asia/Kolkata, or America/New_York. Default: none. | UTC |
| Merge Options Compliance Level | No | OOXML compliance standard for the output document. Options: ECMA (ECMA-376 2006), Transitional (ISO 29500 Transitional, default and recommended), Strict (ISO 29500 Strict). Use Transitional for broadest Microsoft 365 compatibility. | Transitional |
Output Fields
| Field | Type | What it contains |
|---|---|---|
document | Binary | The merged Word document as a binary. Map into SharePoint Create File, Send Email attachment, or a Convert Word to PDF action. |
Success | Boolean | true if the merge completed without errors. Use in a Condition step to branch on failure and send an error notification. |
Error Message | String | Human-readable error description if Success is false. Null when successful. Include in failure notification emails. |
Errors | Array | Array of detailed error objects when Success is false. Each entry has Code and Message fields for debugging. |
Common Error Messages
| Error Message | Cause | Fix |
|---|---|---|
| No documents to merge | Documents array is null or empty | Pass at least one document object in the Documents array with Filename, DocContent, and SortPosition. |
| Error loading document from bytes | Invalid or corrupted Word file in DocContent | Verify DocContent comes from a Get File Content action returning a valid .docx binary: not a URL or path. |
| Unknown FormatMode, defaulting to KeepSourceFormatting | Invalid FormatMode value | Use only: KeepSourceFormatting, KeepDifferentStyles, or UseDestinationStyles. |
| Error merging documents | General exception during merge | Check that all documents are valid Word files (.docx). Review the Errors array for details. |
Quick Setup
- In your Power Automate flow, click + Add an action and search for PDF4me Word.
- Select Merge Documents.
- Enter your PDF4me API key in the connection dialog (or select an existing connection).
- For each document to merge, add a SharePoint Get File Content or OneDrive Get File Content action above this step.
- In the Documents array, add one entry per file. Set Filename (with
.docx), DocContent (binary from the Get File Content step), and SortPosition (0 for the base, 1, 2... for subsequent files). - Set FormatMode: use
UseDestinationStylesif the base document (position 0) is your branded template. - Set Merge Options Compliance Level to
Transitionalfor broadest compatibility. - Wire the document output into a SharePoint Create File or Send Email action. Add a Condition on Success to handle failures with an error notification.
Workflow Examples
Workflow ExamplesCommon Power Automate flow patterns using Merge Documents.
- A SharePoint item change triggers the flow when all report sections are marked "Approved" in a status column.
- Four Get File Content steps retrieve the cover page (position 0), executive summary (1), main body (2), and appendices (3) from the Reports library.
- Merge Documents combines all four in SortPosition order with FormatMode set to UseDestinationStyles, the cover page template's styles apply uniformly throughout.
- A Condition on Success routes failures to a Teams notification for the report owner.
- Send an Email attaches the merged DOCX report to the management distribution list. SharePoint Create File archives it in the Published Reports library.
- An approval trigger fires in Power Automate when the legal review step is completed in the contract approval workflow.
- Get File Content steps retrieve the contract header (0), Terms & Conditions (1), specific clauses (2), and signature pages (3) from the Legal library.
- Merge Documents assembles the complete contract. FormatMode is KeepSourceFormatting and Compliance Level is Strict for legal document standards.
- A PDF4me Convert Word to PDF action generates a print-ready PDF of the merged contract.
- Send an Email delivers the numbered, final contract to counterparties. SharePoint archives both the DOCX and PDF in the Executed Contracts folder.
- A manual trigger fires when a proposal is ready. SharePoint Get Files retrieves all DOCX sections from the Proposal Sections folder for that deal.
- An Apply to Each loop iterates over the file list. Each iteration runs Get File Content and appends a document object (Filename, binary, iteration index as SortPosition) to an array variable.
- After the loop, Merge Documents receives the complete array. FormatMode is UseDestinationStyles, the first file in the folder (position 0) is always the branded cover template.
- The merged DOCX uploads to the Client Deliverables SharePoint library. Send an Email delivers it to the client contact with a personalized cover message.