Press "Enter" to skip to content

Convert Microsoft Forms Responses to Word or PDF Documents

We’re really excited to announce that our new Power Automate action ‘Convert HTML to Word‘ is now globally available within all Microsoft Power Automate regions. The action is fairly self-explanatory as usual, it allows either a HTML file, HTML data or a URL (Results) to be converted into a Microsoft Word document!

If you’re looking to convert to PDF, please check out this article on our support site: Convert HTML to PDF

Scenario

Our support team periodically issue a customer satisfaction survey using Microsoft Forms. We need to get the results of each response and generate a word document containing extracted results allowing a support representative to pickup the document and apply further comments for internal records.

Guide

1. Setup and create a Microsoft Form which is configured to capture the required information.

2. Create a new Flow using the ‘Automated — from blank‘ option

3. Enter a name for the Flow, select the SharePoint ‘When a new response is submitted‘ Forms trigger, click ‘Create

4. Select the target form

5. Add a ‘Get Response Details‘ action

5.a. Form ID: Select the form as per step 4

5.b. Response Id: Select the ‘List of response notifications Response Id‘ from the ‘When a new response is submitted‘ action

6. Add the Encodian ‘Convert HTML to Word‘ action

6.a. Filename: Enter the name of the output file (docx). You may wish to generate a unique filename by using the concat expression such as:

concat('FormsToWordDemo-',utcNow(),'.docx')

6.b. HTML Data: Copy and paste the HTML data into the field. This demonstration uses this simple HTML snippet:

<html>
	<head>		
		<meta charset="UTF-8">
	</head>
	<body style="font-family:arial">
		<div style="padding-left: 12px;">
			<h2>Encodian Customer Satisfaction Survey</h2>
		</div>
		<div>
			<table style="width: 100%;"  cellpadding = "10">
				<tbody>
					<tr>
						<td><b>Submitted By<b></td>
						<td></td>
					</tr>
					<tr>
						<td><b>Submitted On<b></td>
						<td></td>
					</tr>
					<tr>
						<td><b>Overall, how satisfied are you with our company?<b></td>
						<td></td>
					</tr>
					<tr>
						<td><b>Please explain your satisfaction level in the question above.<b></td>
						<td> </td>
					</tr>
					<tr>
						<td><b>How well do our products meet your needs?<b></td>
						<td> </td>
					</tr>
					<tr>
						<td><b>How would you rate the value for money of the product?<b></td>
						<td> </td>
					</tr>
					<tr>
						<td><b>How responsive have we been to your questions or concerns about our products?<b></td>
						<td> </td>
					</tr>
					<tr>
						<td><b>How long has your organization been a customer of our company?<b></td>
						<td> </td>
					</tr>
					<tr>
						<td><b>How likely are you to continue doing business with us in the future?<b></td>
						<td> </td>
					</tr>
					<tr>
						<td><b>How likely are you to recommend our company to a friend or colleague?<b></td>
						<td> </td>
					</tr>
					<tr>
						<td><b>Encodian Comments<b></td>
						<td> </td>
					</tr>
				</tbody>
			</table>
		</div>		
	</body>
</html>

6.c. To interlace the response data simply place your cursor in the target location within the HTML and select the required response field from dynamic data

6.d. Complete for all required fields

7. Add a ‘Create File‘ SharePoint action

7.a. Site Address: Set to the target SharePoint site

7.b. Folder Path: Set to the target SharePoint library and folder

7.c. File Name: Select the ‘Filename‘ field from the ‘Convert HTML to Word‘ action

7.d. File Content: Select the ‘File Content‘ field from the ‘Convert HTML to Word‘ action

8. Test the Flow by submitting a response to the target Microsoft Form

9. Validate the flow run has successfully executed

10. Check the Word document has been created

11. Validate the Word document with Microsoft Word

The ‘HTML to Word’ action also allows the conversion of HTML files and data retrieved from a URL.

We hope you’ve found this guide useful, as ever please share any feedback or comments, all welcome!

NOTE: HTML layouts are constrained by the HTML support provided by Microsoft Word. If you have a complex div / js / css based layout you may experience some challenges.

11 Comments

  1. Eric Halsey Eric Halsey

    This is great and I’d like to extend it a bit. We have tons of Google Forms we are migrating to MS Forms. One of the missing features is automatically creating a PDF of the response. Wondering if there is a cleaver way to auto-magically create an HTML table for each answered questions with 2 columns the first for the question and the second with the answer. That way we can re-use the same actions for all of our Forms without having to explicitly create the HTML as in your example. I can get the JSON data but as you might be aware it only includes the question ID’s and not the actual question text. Thanks in advance.

    • Jay Gooodison Jay Gooodison

      Hi Eric,

      There is no magic way of auto generating the HTML table data. If preferred you could make use the ‘Create HTML Table’ action in Power Automate, an example for this is provided here: https://blog.encodian.com/2020/01/convert-sharepoint-list-items-to-pdf/
      Check out steps 5 > 6 in the ‘Convert multiple SharePoint List Items to PDF‘ section
      I don’t think does solve your challenge however as you still need to pass the data from each individual form, and given the ID’s of the questions will be different you would need to update each time.
      If you need further help please raise a support ticket via https://support.encodian.com/hc/en-gb/requests/new

  2. Hello, this is a great capability! Glad I found it. I am trying to use the responses to populate fillable fields in a MS Word document. Basically it is a estimate form where I update the address field and several fields throughout the document using inputs from the MS Form responses. Is this possible?

    • Jay Gooodison Jay Gooodison

      Hi Bill,
      Absolutely, this post covers how to update data in either a word or PDF document – Populate a Word or PDF Document using Power Automate
      The example uses data from SharePoint, but you’d just swap out for data obtained from a Microsoft forms response.
      HTH
      Jay

  3. Socrates Socrates

    Hello, Thank you for creating this useful tool. Is there a way to make the make the flow compatible with branching? Some questions on my forms are only asked dependent on the answers on a previous question.

    • Jay Goodison Jay Goodison

      Hi, our connector is compatible with branching. You simply need to configure your flow to only populate sections of your HTML where a response has been provided. Please contact our support team if you require further guidance. HTH Jay

  4. Ramon Ramon

    Good night, I would like to add the attachment images that are loaded in the forms, how could I add the replies and those images in the Word document?

  5. Zorica Latinovic Zorica Latinovic

    Hi! I followed all the steps, but the flow reports an error:
    {“HttpStatusCode”:400,”HttpStatusMessage”:”Bad request”,”OperationId”:”08f6d56b-4332-4c35-ab78-35db392411bf”,”Errors”:[“Please provide either a HTML document, HTML data or URL and not more than one of these options.”],”Operation Status”:”Error”,”Filename”:null,”FileContent”:null}
    Can you help me? How can I resolve this?

    Thank you in advance!

    • Jay Goodison Jay Goodison

      Hi Zorica,
      The error message is stating that you are not passing any data… there is no file, HMTL data or a URL being passed hence why you are getting a ‘Bad Request’ error message.
      You can see what data is being sent by reviewing your run history and checking the inputs / outputs.
      For further support please raise a ticket
      HTH
      Jay

Leave a Reply

Your email address will not be published. Required fields are marked *