Generate a document from a template with Microsoft Power Automate

Patrick Perlmutter
April 2, 2021

How to fill in the fields of a word document with a form?

Before you start, try the public version of this automation 👇

In order to give you an idea of the final result of this automation, we provide you with a form for cancelling your mobile or internet subscription.

We all need it regularly don't we? 😇

Once you have answered the 10 questions in the form (2 minutes), you will receive an email with a link to the automatically generated document 

You will find below a simple tutorial to set up this automation on your own.

It's up to you!


This automation is for you if:

  1. You write the same document (contracts, letters, etc.) systematically by replacing certain specific parts;
  2. You are collecting information that you should send by mail or in an official document;

Good to know

To set up this automation, you need to know 

1) that the document setting can only be done on Windows ;

2) and only the Microsoft Word desktop application provides access to the necessary parameterization features.

Writing the template text with Word

Drafting the text of the document

Open a blank Word document in Microsoft Word for desktop and save it as "Template.docx".

Write the following three lines:

First name : 

Name: 

Date: 

The automation we will create will allow us to automatically introduce variable data to the right of the two points.

Activate the "Developer" tab to access the Content Control features

If you see the Developer tab in the main ribbon, you can proceed to the next step. If you do not see the tab, you will need to enable it.

Customizing the Word Ribbon

Right-click in an empty space on the Word Ribbon to display the customization options. Select the Customize Ribbon... option.

Activating the Developer Tab

The window that opens shows you the options for customizing the Ribbon. In the list on the right, check the box to enable the Developer tab and then click OK to close the window.

Microsoft Word Developer Active tab

You should now see the Developer tab in the Ribbon.

Make the model dynamic with the Content Control

Click to the right of the colon in the first line where you wrote First Name.

Application of the plain text check

On the Developer tab, select the Plain Text Control option. In place of your cursor, you should see a content control field appear.

Activating Design Mode

To view the settings for this field, first select Design Mode from the Developer tab.

You should see a blue highlight that looks like a thick parenthesis.

Access to the Control Property

Click the blue item and return to the Developer tab. Click on Properties.

Naming of the control field title

In the window that is proposed to you, simply add the name of the variable field in the Title field of the window In this case, the text to be added in the Title field is "First name". Click OK to close the window.

Setting of all control fields

Your dynamic field is now active and available in Power Automate. Repeat these steps for the 2 other fields.

Save your document and then go to Power Automate.

Setting the Power Automate trigger

To simplify the use of this automation, we will set up a manual trigger. You can use a form or any other data source to feed your Word document template.

We will add 3 entries to the manual task to reflect the fields to be populated in the Word template.

Setting the Power Automate trigger

Click on Add Entry... and select the Text option. In the left hand column, replace the text "Entered" with "First Name". Repeat this process for the other two fields, "Last Name" and "Trigger Date". For the third entry, select Date instead of Text.

Automatic filling of the Word template

Click to add a task after the trigger. In the search bar, type "Fill in a Microsoft Word template". The option appears in the drop-down list. Select it.

Selection of the Word template to be filled in

Browse and select thelocation and document library that matches the location of your Word template.

In the File field, browse to identify the template document and select it.

Selection of the data to be added in the fields

When you have selected the correct file, you will see the fields you set up in the first step of this tutorial.

Click in the field that corresponds to the first name. The dynamic content menu appears. Scroll to find the First Name variable from the Trigger Task. Click it to add it to the first name field. Repeat this process for the other two variables: last name and date. 

Complete setting of the Word document filling

We are almost there! This last task does not create the file we need. It simply fills in the template and gives us back the contents of a file.

Creating and saving the auto-generated file

Add an additional task. Find the SharePoint task, Create a file and add it to the feed.

Add a file creation task

Choose thesite address and folder path where you want to save the auto-generated document.

To avoid possible conflicts when saving, it is necessary to give a unique name to each auto-generated document.

Writing the unique name expression

Click in the File name field. In the dynamic content menu that appears, click the Expressions tab. In the field, write concat() to use the concatenation function that allows us to join texts together into a single string.

Put your cursor inside the brackets. Then switch to the Dynamic Content tab. Scroll through the list and select the First Name variable. Then type , to add a comma after the first name in the input field. Go back to the menu and select the Last Name variable and type a second comma. Finally, after this last comma type utcnow(), again inside the parentheses. This will add the precise date and time of when the stream is running to ensure a distinct name. Click OK to complete the field.

Create a single file from the Word template

To ensure that the file is in the correct format, add the extension ".docx" after the phrase directly in the field.

Put your cursor in the field, File Contents. From the dynamic content menu, select the output of the last task, Microsoft Word Document.

Launching the Power Automate flow

Save your feed and test it. The first time you launch the feed, Power Automate will ask you to enter a first name, a last name and a date. 

Automatically filled Word template

Go to the SharePoint folder you selected in the SharePoint file creation task. You can find the auto-generated document here.

Bravo ! You're a pro at filling in documents automatically!

It's here to download the model 👉 here

If you wish to access the complete solution illustrated in this example, please complete the form. In addition to the self-generated document download link, you will receive a link to download the Power Automate solution that you can deploy on your own account.

Start automating your business today.

Get in touch with us and start identifying opportunities to automate and digitalize your business on your Microsoft Office 365 suite.