+44 1384 593720

©2020 by Vantage 365 LTD

Placing a QR Code in a Word Document

It is quite a common requirement that QR codes are placed into the body of a document to help with data encoding and retrieval later. They are commonly used in libraries where key document information can be scanned. We can use Power Automate along with the Vantage 365 Imaging connector to do exactly this.

Preparing your Document

The first thing that you need to do with your Word document is prepare it to receive data from Power Automate. First of all open Word, and either start a new document or open a document where you want to inject content.

Along the top menu bar, you should see the Developer tab. If you can't see this tab, please read "Show the developers tab" on the Microsoft site. On the tool bar, you will see a group called "Controls" which allows you to select what type of content you want to place into your document.

For this example, I am going to select a Rich Text Content Control, and a Picture Content Control. I am going to use both of these controls to create a postage label, so my text will contain a name and address, and my image will contain a QR code.

Once I have those controls in my document, I need to give them a title so that they appear with a "friendly" name when I use my Word actions in Power Automate. To give it a title, click on the relevant control, and then click Properties in the Controls group on the Developer menu.

Once you have given the control a title, press OK. Now repeat the same process for any other controls that you have placed on the page.

Save your document, I have called mine "Postage Label Template.docx" and upload it into SharePoint so that we can use it within our Flows.

Now that we have the template created, and uploaded to SharePoint, let's create a basic list to contain the detail we need to pass into our Word Document. I have created a basic list and added a column called Address.

Now that we have all of the constituent parts in place, let's go and create a Flow to populate create a Word document with the postage information populated.

Creating the Flow

The Flow which I will create will do the following:

  1. Trigger the Flow when an item is added to the Labels list

  2. Generate a QR code and save the image to SharePoint

  3. Populate the Word template with content

Let's start with creating the Flow and creating a new document based on the template.


The Flow will be initiated by using the "When an item is created" trigger from the SharePoint connector. This will run each time a new item is added to the list. I will simply configure it to look at the "Labels" list.

Now that we have the trigger in place, let's generate our QR code.

Generate the QR Code

The first thing we are going to do is encode the address into a QR code in order to put it into our Word document later. So let's put the "Generate Basic QR Code" action, from the Vantage 365 Imaging Connector into the Flow, and tell it to encode the Address dynamic content from the trigger.

For the Microsoft Word document to accept the image returned, it needs to be transformed into a binary encoded PNG file. The easiest way to do this, is to create a file within SharePoint which we can then use later. In order to create the file, I need to isolate the Base64 String from the QR code. In this demo we'll do this in an "Initialize variable" step. In order to isolate the part of the string, I need to use an expression to split the string on the comma "," and take the second part only.


Once I have the Base 64 string isolated, I can then use the "Create file" action from the SharePoint connector to create the file within SharePoint. Again I need to use a small expression to ensure that the string is in the correct format by using the base64ToBinary formula.

base64ToBinary(variables('Base 64 String'))

The unfortunate thing with this action is that I can't then get the encoded file content directly from the Create file action, so I need to put an action in to "Get file content". We can, however, use the ID from the Create file action to get the content of the file.

Now that we have the QR code, and we have it formatted in a way that Microsoft Word will accept, let's place populate the template.

Populate the Template

Now that we have all of the data we need, we can use the "Populate a Microsoft Word template" action from the Word Online (Business) connector. When we place it onto the screen, we need to select the template which we're going to populate. Once that has been done, it will understand what fields are available to be populated and you can then take the dynamic content from the previous actions and use them here. For the Address, we can use the Address dynamic content from the trigger, and for the QR code we can take the Content dynamic code from the "Get file content" action.

The final thing that we need to do, is to create a file based on the populated Word template. Again, we can simply use the "Create file" action to save the populate file, and store it within SharePoint.

Now that we have completed our Flow, you can trigger it and observe the output.

What we've created

Once our Flow has executed, it will take the Address from the SharePoint list and encode it in a QR code. That QR code is saved as an image and then pushed into a Word document which we've saved back to SharePoint.

We have now created a Flow which will encode the contents of a SharePoint list into a QR code and then pushing it into a Word Document.. If you are interested in using the QR code visit the Vantage 365 Store or alternatively contact sales@vantage365.co.uk.