Create Documents Instantly with Power Automate

PowerAutomate

A while ago, I was asked about the possibility to automate creating documents. Recently, a friend asked the same question. Her organization is hoping to develop a homegrown solution instead of purchasing a tool that fails to do everything they need it to do. I’d worked out a pretty quick solution and thought to share it here, too.

First Things, First

Is automation worth it? For automatic document creation to work well, the document to be created should be commonly used. I mean, why go through all the trouble of creating a solution for a document that is only used once or even once a year?

Get It Together

Procure the document

Have the latest version of the document to be automated available. If it doesn’t exist, yet, create it. Triple-check all spelling, grammar, and punctuation. Triple-check the formatting and use formatting styles. A properly formatted document is a healthy document, after all. Have all necessary parties approve the content and the formatting. This is key.

Review the document for automation

There are parts of the document that never change and parts that will change all of the time. Note the parts that change all of the time. For example, in a form letter, the letter body stays the same but maybe the letter date, addressee, and salutation changes each time.

There may also be parts of the document that change sometimes and you may know what how those parts change. Make a note of that, too.

Create a SharePoint List

The SharePoint list will serve as the repository for the parts of the document that change all of the time and the parts that change sometimes. In the new SharePoint list, make a column for each part of the document that changes/can change. For example, if the document is a business report, the report name changes every time a report is created. Create a single line text column called ReportName in the SharePoint list to capture the report’s name.

Consider creating a choice column for document parts that change sometimes. For example, if the document is a form letter sent to exempt and non-exempt staff, you may want the option to pick the applicable text for the right situation. While creating the choice column, paste the choice text for each choice.

Prepare the document template

Open your document and save it as a new document in a SharePoint document library in the same SharePoint site as the SharePoint list you already created for this purpose. Save the document as a .docx file.

Enable the Developer tab on the ribbon and use the text box field to replace the sections of the document that change. Give each text box field a relevant name. Extra points for keeping the name consistent with the column names in the SharePoint list. Save the document and close it.

Create your Flow in Power Automate

Launch Power Automate and complete the following steps:

  1. Create a new Flow for when an item is created in a SharePoint list.
    1. Select your SharePoint site address.
    2. Select your SharePoint site list. Add a New Step.
    3. Select the Populate a Microsoft Word template as the new step.
      1. Select the SharePoint site address (this where the template is saved).
      2. Select the document library.
      3. Select the template.
      4. Use the dynamic content to populate the fields. Create a new step.
    4. Select the Create file for SharePoint as the new step.
      1. Select the SharePoint site address (this is where the new documents will be saved).
      2. Select the folder path in your document library (the folder the new documents will be saved in).
      3. Select the file name. I simply used the dynamic ID or Title from the corresponding SharePoint list item but you should use whatever field you used for the document’s title. Add .docx at the end of whatever dynamic field you select or name you type.
      4. For file content, select the dynamic content Microsoft Word Document.
    5. Save the Flow and rename the Flow for relevancy’s sake.
    6. Test the Flow by running it in Test mode and then go add an item to the SharePoint list.
Flow structure for automatic document generation

Make it better

Add a gorgeous PowerApps app as the front-end by connecting it to the SharePoint list. Then users can use the PowerApps app to generate a document while SharePoint and PowerAutomate do the heavy lifting.