Create a Word document automatically from Project Data using Flow

Posted By Posted by: Khurram Jamshed on February 20, 2019

Microsoft Project Online solution enables the storage of project data in a central repository to increase visibility across the organisation. Reporting on that data can be generated using different tools available such as SSRS, Power BI etc.  An example of the reporting output is a nicely formatted Word document with the most up-to-date project status data, for distribution around the organisation i.e. a Project Status Report.

The benefits in generating Word documents for such reports include ease of formatting, PDF conversion, the sharing/printing the document.

In this blog post, I will walk you through the steps of automatically generating a Word document in MS Project Online using a Word doc template. I will also cover the use of MS Flow with the help of the latest Word Online connector (please note that connector is still in preview mode).

The scenario I depict in this post is after entering project data for the project. I will then set a certain flag on a project indicating the data is ready to be populated and the project is ready to be published. Flow is triggered by Project Publish event, which checks the flag value and if it appears as ‘true’ it will then generate a dedicated Word document based upon the template and populate it with the project data.

Let’s look at the first step, the Project Online set-up process:

1. Below is a project I created in Project Online with some basic custom fields on a project detail page.
2. Note that I have deliberately included a flag field of Generate Document.
3. I then updated the fields with some data and saved my project.

Then, let’s prepare a Word document template to be automatically populated at a later stage:

1. In order to prepare a Word doc template, you need to enable the Developer tab. The Developer tab is not displayed by default, but you can add it to the ribbon, the tab can also do several things including inserting controls.
2. To add the Developer tab on your Word application, follow this link: Show the Developer tab
3. Once you enabled the tab, it will appear as below and you can add text content Controls into your document.
4. Go to Design Mode under Controls and enable plain text control on a page, and then use Properties to assign a friendly name to that control.
5. I have prepared a simple Word doc template after adding a few text controls and an image.
6. After preparing the template, I saved it to my PWA Shared Documents library.

Now the last part of this exercise is to bring all of this together with the help of none other than, the actual hero of this post, MS Flow.

 1. To begin in Flow lets first add and configure Project Online trigger of when a project is published:
2.  The second step, under Actions add a send http request to SharePoint. This is where we’ll build oData query to fetch project data. Configure this action as below and give it an easy name to refer to this action later.
3. Optional step: we can save each of the column values to variables so that we can easily use at later steps in Flow. You can also choose to refer to these columns directly by use expressions.

Insert Initialize variable action, and assign each column value using expression:


4.  Repeat the above step for all 4 columns and name each variable appropriately.
5.  In the next step, I’m adding a condition action to check if Generate Document flag was set to ‘true’ or not. If it is, it will populate the document template, and if it was set to ‘false’, it will simply skip the template.
6.  In Yes branch of a condition, I am adding a newly released Word Online Connector to populate my Word doc template. In Actions, add an action Populate a Microsoft Word template as below.
7. To configure the Word doc template, choose OneDrive location for Business and browse to your PWA Shared Documents library. Red text will appear when you try to select a location other than OneDrive.

Note: at this stage, only OneDrive is working as a location to browse your template. It could be due to its Preview version, the other options might be available soon.

Use the sync option available in your shared document library so that it syncs the library with your PWA Shared Documents library in OneDrive.

Once the location is selected, click on the File icon to access Shared document library and choose your template file.

8. Now in my last step, I chose to save the output file in the same shared document library with a date-time stamp. But you can either choose to save the output file to the same project’s site document library or email it or perform any other action for this output.

Now to trigger this flow, I have to publish the project. Once published and the Flow has run successfully, we can see an output Word document file generated and saved automatically in my chosen document library.


And if I open a file, either in word online or download and then open in word, it comes up as a nicely formatted document generated automatically from my project data.

Hope this will help, enjoy.

Blog Posted In Blog Posted In: Blog, How to, Project Online, Reporting
Blog Posted In