Use the Microsoft Word Connector to Automate Document Creation
  • Updated on 22 Sep 2019
  • 2 minutes to read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

Use the Microsoft Word Connector to Automate Document Creation

  • Print
  • Comments
  • Share
  • Dark
    Light

#ServerlessTips - Microsoft Flow
Author: Kent Weare Integration MVP

Azure Logic Apps has traditionally been used to collect data and integrate systems that require this information. These systems may reside in the same organization or across organizations spread out across the globe. However, a new capability has been recently released that allows documents to be created through Azure Logic Apps using the new Microsoft Word Connector.

This new document creation capability provides opportunities to generate contracts and agreements without needing to copy and paste information into Microsoft Word or rely upon expensive third party tools.

In this blog post we will take data from Azure SQL and use it to populate a Word Document using the following steps:
Create all the necessary content for your document
1-worddoc.png
Enable Developer tools in Microsoft Word by clicking on File – Options – Customize Ribbon and then check-on Developer.
2-DeveloperTools.png
For each field that you want to populate add a Plain Text Content Control from the Developer menu.
3-addcontrol.png
Also, ensure that you edit the Properties for each text control so that you can provide a descriptive name which will help when mapping data attributes in the Logic Apps designer.
4-properties.png
Repeat these steps for remaining fields and save to OneDrive for Business.
Note: You do not need to save it as a Microsoft Word template. Just save it as a regular ‘.docx’.
5-finaldoc.png
With our Word document in place, let’s now shift gears over to the Azure Portal where we will build our logic app. Our logic app consists of a Recurrence trigger followed by an Execute SQL query action that will retrieve customer records from our database. We now need to add the Microsoft Word connector and use the Populate a Microsoft Word template action. Within this action, we need to configure where our Microsoft Word document exists within our One Drive for Business folders. We can now map all of the fields that we previously created within our Word Document.

The output of the Populate a Microsoft Word template action is a word document. But, we need to write this content out, in order to use it. We will use the Create file action found in the One Drive for Business connector to accomplish this.
6-logicapp.png

Testing

We are now ready to test our logic app by invoking our trigger. When our logic app completes running, we need to check our One Drive for Business folder to find our newly created file. When we open it, we will discover our template has been populated.
7-testing.png

Conclusion

In this post, we discussed a new feature available in Azure Logic Apps that allows you to use a Microsoft Word document as a template and then send it data from Logic Apps. Considering that Azure Logic Apps has access to more than 230 connectors, this becomes a very powerful scenario as you can now merge data to many data sources, or a combination of data sources, that Microsoft Word previously never had access to.

Was this article helpful?