Power Automate allows the creation of Word document from template.
Use Quick Tips and learn how to automate the process of Word file generation with the metadata.
Power Automate gives the opportunity to automate the generation / creation of the Word document based on a template. Moreover, I will show you how to fill this document with metadata.
Learn how to build an automated process of the Word documents with predefined content in the template and filled with dynamic metadata.
In this automated process we will also use a few features of the SharePoint Document Library:
- Content Types
- Document metadata
- Quick Parts in the Word document
In this article you will learn how to use Power Automate flow actions and triggers:
- SharePoint – Copy file
- SharePoint – Create file
- SharePoint – Update file properties
Technical requirements to create the Word document from template:
- You will need to prepare Word document template – you can use an existing Word file
- You will need to create SharePoint Document Library with metadata columns
- You will need to map Word document content with Document Library metadata using QuickParts
- You will need to save that document as a template.
Creation of the Word document from the template requires 2 steps in the Power Automate:
Prepare Word document template in SharePoint Document Library
Word document hosted on SharePoint Document library allows interconnecting document content with the metadata columns. In such a scenario, you can use a Word document template that will be filled in with metadata values. You can create the document template that will be automatically created and updated with proper data by the Power Automate process.
At the first step, you will need to prepare a document template.
In the next step, you need to create or use SharePoint Document Library. On the SharePoint site select the New (1) button and create a Document Library.
In the new library, create the metadata columns you would like to use to fill the document.
? Not all columns can be used to fill in the Word document. Focus on the use of: Text, People, Choice, Number and Date columns.
Now you can upload the Word template to the document library and open it using Word Desktop application.
In the Word file, you can inject the metadata from the SharePoint library. Go to Insert (1), find Quick Parts (2) and from Document Property (3) you can select metadata – SharePoint columns.
You can inject SharePoint metadata multiple times in the file content. It could save you a lot of time thanks to the dynamic creation of the Wor documents based on such a template.
Created document template can be used by you in the Power Automate process to automatically generate Word files. Thanks for injecting the values from SharePoint metadata columns into the Word document content. Word Desktop app automatically will display the data, Word Online will not. Be aware of that limitation.
? You can use this template and save it as a content type template in the SharePoint Documents Library, but in this, you will need to use it a little different way to automate this process using Power Automate. It is the current Power Automate limitation.
Create Word document from template in Power Automate
You can import Microsoft Excel spreadsheet records to the SharePoint Online list in a few steps
SharePoint – Create file – does not work in this scenario
For some reason SharePoint action – Create file creates corrupted files when you use File content from the prepared template.
You can try if this action will work in the case of your Word document template. In the case of my tests, this action never worked for advanced Word templates which use Quick Parts.
Create Word document from template in SharePoint Library
Now you will be able to create a new Word document from the template in the SharePoint Library. Use Copy file action to generate a new document in SharePoint Library.
To create new Word document from template using Copy action, set:
- Current site address – Select the SharePoint site where all activities should take place
- File to Copy – select your prepared template it could be saved in the dedicated folder
- Destination Site Address – target site where file should be copied – same site used in the first field
- Destination Folder – select folder where file should be saved
- If another file is already there – select Copy with a new name
When you will create a new Word document from a template by copping it using Power Automate it could look like this:
This action will create a new instance of the Word document. In the next step, we will fill it with the data.
Update file properties of the created file and inject them into the Word document content
In the last step, you update the properties of the created Word document. Thanks to the use of Quick Parts these properties will be injected into the document content. Use Update file properties action to do that.
To update the properties of the Word document, set:
- Site Address – Select SharePoint site
- Library Name – select Document library
- Id – Unique Id of the document that. In your case, you should use ItemId which is the result of the previous action Copy file
- Document properties – columns of the document library which you can filled-in
When you will update properties of the Word document created from a template using Power Automate it could look like this:
As a result of this action, you will have the new Word document created from the template and filled with the metadata.
Power Automate allows you to automate the creation of Word documents from templates and fill it with metadata.