Compare Two DOCX Documents in Power Automate

Cloudmersive
4 min readSep 25, 2024

--

It’s common for many rounds of redlining to take place throughout the lifecycle of a legal contract negotiation.

A document that starts out as legal_contract_template.docx can gradually morph into legal_contract_redlines_round_12.docx, and throughout that painstaking process, each independent round of edits can get lost in the shuffle when the next round takes place.

Usually, where a contract template document ends up is quite different from where it starts, and that means it’s extremely useful to summarize — or compare — the entire beginning-to-end change once the negotiation/redlining process is complete. That adds value for our team AND for the team “across the table” from us.

Thankfully, it’s easy to do this with DOCX files. The MS Word application has a feature that lets us compare two DOCX files from within our file system to see the differences between them. This feature highlights the changes from document 1 to document 2 in something akin to track-changes format.

But what if we want to automate this comparison process instead of handling it manually?

As it turns out, that’s pretty easy, too. We can simply head over to Power Automate and start building a flow.

Using the Cloudmersive Document Conversion connector in Power Automate — a published, free-to-use connector version of the Cloudmersive Convert API — we can load and compare any two DOCX files and generate DOCX comparison file bytes within our flow. That means we can easily compare files from the same OR different file systems (including external files attached to inbound emails) and place the results in outbound emails, approvals, SharePoint Lists and folders, and more.

Compare Two DOCX Documents in Power Automate

We’ll walk through a quick, manually triggered example flow to briefly demonstrate the DOCX comparison process in Power Automate.

We’ll start out by adding two Get file content actions to retrieve two different versions of standard DOCX document from our file system. If we don’t have two documents fitting that description on hand, we can look for an online Lorem Ipsum generator, copy/paste that content into two separate documents, and make a few changes to one version of the copy.

Next, we’ll add a new action and look for the Cloudmersive Document Conversion connector.

We’ll click “See more” to view the actions list, and we’ll then CTRL+F search for an action titled Compare Two Word DOCX.

After we select this action, we’ll need to create our connection. As we can see, we’ll need an existing premium Power Automate license to use Cloudmersive connectors (they aren’t built-in, so they’re not part of the basic plan), but we can use them at no additional cost with a free API key. That’ll give us a limit of 800 API calls per month in perpetuity (resetting each month), and we can get one by heading to the Cloudmersive website and creating a free account.

Once we’ve created our connection, we’ll configure our request. This part is simple — we just need to provide file contents and file names for both our DOCX documents. Ideally, our original document should go in the first parameter, and our adjusted document should go in the second.

As a quick aside — we don’t need to provide our real file names in the “File Name” parameters (I’ve temporarily named mine file.docx and file1.docx), but we can if we prefer to.

In our final step, we’ll add a Create file action to generate our comparison document. As mentioned earlier, this comparison API generates a new DOCX file that highlights the differences between document 1 and document 2.

When our flow finishes running, we can open our comparison document and review the results.

We’ll notice strikethroughs and word replacements in our new document (as shown in the example Lorem Ipsum translation passage above) wherever changes were identified in document 2 vs. document 1.

Conclusion

Using this API in Power Automate, we can now easily automate document comparisons at the end of a contract negotiation lifecycle and share the results with all necessary stakeholders. All without writing a line of code!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet