In this guide you’ll learn how to convert InfoPath files to a Word document using Power Automate. Converting InfoPath to Word is a more involved process than other conversion types because InfoPath uses two files to create a single form, an XML (data) file and an XSN (template) file.
In this example, you will create a simple Flow that is triggered whenever a form is added to a folder in a SharePoint Online Library. Once this is added, the form is automatically converted to a MS Word document and stored in SharePoint folder.
This example can easily be adjusted to use different file services (e.g. the trigger can be for files uploaded to OneDrive, Box.com, DropBox, Google Drive or can even be used to Migrate your SharePoint On-Premise InfoPath Forms to SharePoint Online etc).
Before we begin, please ensure the following prerequisites are met:
- Make sure you have a Muhimbi PDF Converter for Power Automate
- Make sure you have the appropriate privileges to create Flows.
Using PowerAutomate to Convert to DOCX
Here’s how to convert InfoPath files to Word in SharePoint using Power Automate.
Note: Converting an InfoPath form is similar to converting any other document type using Muhimbi's Flow Actions, but you will also need to pass in the XSN file (the file content, not the URL to the file) alongside the XML file.
This example takes you through converting a MS Infopath file to MS Word document. On a high level perspective, the steps to create are as follows:
Create a new Flow and use the SharePoint Online trigger ‘When a file is created’. Fill out the URL for the Site Address and select the relevant SharePoint folder.
Insert ‘Get File Content’ action and specify the path to the SharePoint Online location where the XSN has been published to. (By default it is stored in the Forms Folder, e.g. *‘https://yourdomain.sharepoint.com/sites/Sitecollectionname/Library/Forms/template.xsn’
Insert Muhimbi’s ‘Convert Infopath document’ action, and fill it out as follows.
Source file name: ‘File name’ the output from the ‘When a file is created in a folder’ trigger.
Source file content: ‘File Content’ the output of the ‘When a file is created in a folder’ trigger.
Output format: DOCX
Template file content: ‘File Content’ the output of the ‘Get file content’ action, which contains the InfoPath XSN file.
View names: Enter the comma separated view names that needs to be converted to PDF
Include attachment: If you would like the attachments to also be converted to PDF, select Yes.
Attachment action: Select the action that you like to do with attachments. You can choose from Default, Merge, AttachAsPDF and AttachOriginal. For our example, we will select ‘Default’.
Unsupported attachment action: Select what to do with attachments which cannot be converted into PDF. You can choose from Error, Remove, and AttachOriginal. For our example, we will select ‘Remove’.
Break merge on error: Select if the conversion has to be stopped when processing of an individual part fails. You can select from Yes or No. For our example we will select ‘Yes’.
Include attachment filter: Enter values such as commas if you like to allow filters. Comma separated values, e.g. *.txt, June???.docx. We will leave this empty for our example.
Exclude attachment filter: Enter values such as commas if you like to exclude filters. Comma separated values, e.g. *.txt, June???.docx. We will leave this empty for our example.
Default paper size: Select the paper size to be used if not specified in the view.
Default paper size (custom): Enter the paper size to be used if Default paper size ‘Custom’ is used.
Force paper size: Force the paper size to be used regardless of whether it is set in the views or not.
Force paper size (custom): Enter the paper size to be used if Force paper size ‘Custom’ is used.
Default page orientation: Select the default page orientation for the PDF.
Force page orientation: Force the page orientation to be used regardless of whether it is set in the views or not.
Start page: Select the first page to include in the PDF.
End page: Select the last page to include in the PDF.
Conversion quality: Select the quality of the output file.
Note: Do not just pass the path to the XSN file into the Muhimbi Action as it doesn’t have the privileges to read that file.
Insert a ‘Create File’ action to write the converted file back to the OneDrive folder where the converted DOCX files are written to. For the Folder path, specify the path to the OneDrive folder. For the File Name, pass in the 'Base file name' field returned by the ‘Convert Document’ action, along with '.docx' suffix. In the File content field pass the 'Processed file content' returned by the ‘Convert document’ action.
You can write the converted file back to OneDrive folder, or Dropbox, or Google Drive, or you can send the DOCX via email.
- Publish the workflow and upload a MS Infopath file in the specified document library. After a few seconds the Flow will trigger and a DOCX file will be generated.
Please note that this is just a basic example. Muhimbi PDF Converter also comes with facilities to convert files attached to InfoPath forms as well as choosing which InfoPath view or views to convert. For more information, please feel free to contact our friendly support teams.