Create Documents with Power Automate
Complete guide, demonstrating how to create new Word Documents based on a template, and any combination of text, images, documents and tables.
Last updated
Complete guide, demonstrating how to create new Word Documents based on a template, and any combination of text, images, documents and tables.
Last updated
In this example we’ll be achieving the following objective with a fictional organisation named “10docs Ltd”.
10docs is working to professionalise the way they invoice their clients. They have worked on a new Word based Template (Word Invoice Template) that includes their branding, a layout, and the basic content they would like to use.
The template looks like this:
Power Automate is a growing platform, with an enormous number of first and third party connectors. Tendocs works with them all.
To keep it simple, this example uses the following connectors:
SharePoint for Template storage
SharePoint and Excel for Tables
SharePoint and Variables for Text
SharePoint and Variables for Tables
SharePoint for Image and Sub-document storage
Tendocs for Creating the Document.
If you need any help along the way, feel free to reach out to the support team.
So you can test this yourself, exactly as described here, you can download copies of all the assets used. To get started, all you need is a SharePoint site with a Document Library.
The Company Logo.
The Client Logo.
the Terms and Conditions document.
In addition to the above, some steps are shown using information from SharePoint Lists. The definition of these will be shared later.
To keep things simple, we’re going to start with what Microsoft calls an “Instant Cloud Flow”. It means we can run the flow at the click of a button.
Go to the Power Automate home page.
Create a new Flow “Instant Cloud Flow”, and then complete as follows.
Add a “Get File Content” action to the Flow, and then reference the company logo.
Rename the action to “Company Logo” to make it easier to work with later.
Add another “Get File Content” action, select the “Client Logo". Rename the action to “Client Logo”.
Add another “Get File Content” action, select the “Terms and Conditions” document. Rename the action to “Terms and Conditions”.
Add another “Get File Content” action, select the “Word Invoice Template”. Rename the action to “Word Template”.
The references to the files so far have been static, however, in the case of the client logo, this would be dynamic can come from a “Clients” list, or some other source. You might also have different office templates foe the invoice, and even different company logos. All of this is possible with Power Automate, but beyond the scope of this simple demo.
The invoice line items can be sourced from a number of different places. Tendocs is flexible enough to work with them all. Provided below are common examples to get you started.
You can retrieve table information, in this case the invoice line items, directly from a Table in an Excel file. You could do it by having a dedicated file per invoice, or, by performing a dynamic filter using the capabilities provided by the Excel connector.
Add the “List rows present in a table” Excel (Business) action, select the SharePoint Site, Document Library, and then the Excel File. Choose the “InvoiceLines” table, and then for example add a filter to retrieve only those items for a specific invoice.
Rename the action to “Invoice Line Items”.
The most common feature of a template is being able to replace simple text values. These too can be sourced from a number of different places. Tendocs is flexible enough to work with them all. Provided below are common examples to get you started.
You can retrieve text replacement information from a Table in an Excel file. It could be a dedicated file, but more likely one with a table containing information about all invoices which is filtered using the capabilities provided by the Excel connector.
Add the “Get a row” Excel (Business) action, select the SharePoint Site, Document Library, and then the Excel File. Choose the “Invoices” table, and then select “ID” for the “Key Column” and 1 for the “Key Value”.
Rename the action to “Invoice Details”.
The previous steps have completed all the preparation necessary to automate the creation of invoices.
Both the company and client logos have been retrieved.
The Word Template have been retrieved.
The document that contains the Terms and Conditions has been retrieved.
The Invoice Line Items have been sourced from three possible locations.
The Invoice Details have been sourced from three possible locations.
The next and most important step is to put it all together using the Tendocs Documents action.
Add the Tendocs “Create New Document from Template” action.
The first time you add the action, you will also need to establish a new “Connection”. The new connection screen will look like the following:
Enter the details as follows:
Enter a new name for the connection, so that you can identify it later.
The API key should come from the “Profile” page on the Tendocs website, after following the “Sign up” instructions.
When complete, click on “Create”.
Expand the “Show Advanced Options” link to show the following:
Complete the fields as follows:
Template File: “Word Template” - “File Contents”
Text: “Invoice Details” - “Body”
Image Token 1: “CompanyLogo”
Image File Content: “Company Logo” - “File Contents”
Add another image by clicking “+ Add new item”
Image Token 2: “InvoiceToLogo”
Image File Content: “Client Logo” - “File Contents”
Document Token 1: “TermsAndConditions”
Document File Content: “Terms and Conditions” - “File Content”
Table Token 1: “InvoiceLines”
Table Rows 1: “Invoice Line Items” - “Body - List of Items”.
Important: Be sure to select the “Body - List of Items” and not “Value - List of Items”.
Document Format: Select the format for the document “Original”.
Configuration Keys: Provides for advanced configuration scenarios.
The final step is to connect an action to save the document to the location we want to store it.
Add the SharePoint “Create File” action.
Select the destination SharePoint site, then a Folder Path. You will need to set a filename, which will most likely require some logic to avoid overwriting other generated documents.
In the “File Content” section, add the “File Content” from the Tendocs Action.
All the pieces are now in place, all that is left is to test the new flow.
After saving the Flow, click on the “Test” button, select “Manually” for the trigger, and then click “OK”. You may be prompted to check or create connections, where you can “Continue” and then “Run Flow”.
After a short period of time, the Flow should complete successfully, and you will find the document created with all the merged information.
The final result is a brand new document that is the combined result of the Word Template provided, the Images, Tables, Documents and Texts.
Download the document to see for yourself.