Convert InfoPath Form to Word in SharePoint

Information

Stay informed about InfoPath deprecation and explore alternatives with our PDF converter solutions. Watch the recording of our latest webinar and learn how to convert your InfoPath documents using Power Automate, Nintex workflows, SharePoint Designer, and code.

In this guide you’ll learn how to convert InfoPath Forms to MS Word files in SharePoint using Muhimbi Document Converter. The InfoPath to MS-Word facility can generate output in doc, docx, rtf, txt, html and odt formats. This guide can be used in SharePoint Online or On-premises deployments.

There are some limitations to these conversions due to the nature of the non-PDF-based destination formats:

  1. Attachments: When converting an InfoPath form to MS Word, the software does not work in the same way as PDF which also converts all attachments and merges them into the main PDF document.

  2. View Selection: The software provides a number of ways to specify which view or views to convert. When converting to MS-Word it is only possible to convert a single view as these file formats don’t support merging like how PDF supports them.A workaround for getting all views in a single MS Word document is to create a ‘conversion specific view’ and then to combine the content of multiple views in it.

    Note: Print Views are ignored when converting to MS Word. You can use Muhimbi’s View Selection facilities if you wish to convert any view other than the default View.

  3. Formatting: PDF is a very flexible format that allows any content to be placed anywhere on the page. However MS-Word is not necessarily as flexible as PDF and you may need to optimize your InfoPath form for conversion, or create a ‘conversion specific view’.

Selecting InfoPath Views to Export to MS Word

Muhimbi Document Converter allows you to select specific views to export. However when converting to MS-Word, it is only possible to convert a single view as these file formats don’t support merging like how PDF supports them. A workaround for getting all views in a single MS Word document is to create a ‘conversion specific view’ and then to combine the content of multiple views in it.

In this scenario we have an Employee Review form with the following three views:

  1. Employee Data Entry (default view): This is a view used for populating the data in the MS SharePoint List using the InfoPath client or Forms Services. This is the default view which is usually selected for conversion to MS Word.

  2. Employee Data Entry (print view): A special view that is optimized for printing to a network laser printer. This is specified as the print view. However as Print Views are ignored when converting to MS Word, you can use Muhimbi’s View Selection facilities to select this view to convert.

  3. _MuhimbiView Employee Data Entry (Doc Export view): A conversion specific separate view containing all views that is used to export the InfoPath form to MS Word format. When converting to MS-Word it is only possible to convert a single view as MS Word doesn’t support merging like how PDF supports them. A workaround for getting all views in a single MS Word document is to create a ‘conversion specific view’ like this one combining the content of multiple views in it. You will need to start the name of the view with “_MuhimbiView”. The Muhimbi Document Converter will detect this view that start with this name, and export them into a MS Word document. Note: You can hide these views from the end user by marking them as such in the properties of the view.

doc export view

This is a handy feature of Muhimbi Document Converter if you know beforehand that you will always be exporting the same view(s) to MS Word format.

Determine at Runtime InfoPath Views to Export

There are times when you need to export different views depending on the state of the data. In order to achieve this, you can do the following steps:

Let us design an Employee Expense Claim form, where we need a MS Word document to be generated once the employee creates the expense claim. A second MS Word document needs to be generated once the manager approves the claim.

In this scenario, our Expense Claim form consists of the following Views:

  1. Expense Claim (default): Used by the employee to report expenses.

  2. Expense Claim (approve claim): Used by the manager to add comments and additional information for approval.

  3. Expense Claim (Doc Export report): A conversion-specific separate view that exports the form to an MS Word document after the employee has submitted it but before the manager has reviewed it.

  4. Expense Claim (Doc Export approve): A conversion-specific separate view that is used to export the form to MS Word format after the manager has reviewed the form.

doc export approve

We can implement this by adding a (hidden) text box named “_MuhimbiViews” (case sensitive and using the default ‘my’ namespace) to any of the views and populating it with the name of the view name. The Muhimbi Document Converter will automatically pick up this view and export it to MS Word format.

Note: You cannot specify multiple views; even if they are specified, only the first view in the list (which is the default view) is converted.

In addition to adding the “_MuhimbiViews” text field to the form, all the developer of the form needs to do is add a little bit of logic by creating multiple Submit buttons and enabling one of these buttons when the employee submits the expense report and enabling another Submit button when the manager reviews and approves the expense report. When one submit button is enabled, the other can be disabled and hidden.The developer of the form needs to also add a little bit of logic to each of the Submit events of the form to specify in the “_MuhimbiViews” field which specific view name to export.

Note: The export to MS Word does not export attachments like converting to PDF.

Converting InfoPath to MS Word Using MS SharePoint Designer

One of the more popular features of the Muhimbi Document Converter for SharePoint is the ability to control which view to convert to MS Word. It is even possible to specify which view to convert depending on the form’s current status.

The view that needs to be converted can be specified during design time, or at run time using a little bit of custom code or InfoPath rules. You can also control which views to convert using MS SharePoint Designer workflow. The example provided below uses MS SharePoint Designer workflow. But this works equally well in the Nintex workflow as well.

Creating the InfoPath Form

  1. Navigate to the MS SharePoint List where you want to design the Infopath form.

  2. Go to Site Settings → Form Options and click Customize the current form using Microsoft Infopath and click OK button.

    site settings form options

  3. InfoPath Designer for the list opens.

  4. Create a Text box and name it ‘_MuhimbiViews’.

    create text box

  5. On Page Design tab select New View and name the new view ‘FormView’. Change the Title at the top to ‘Form View’.

  6. Select the fields you like to see in this view and design the Form View accordingly.

  7. On Page Design tab select New View again and name this view as ‘DocView’. Change the Title at the top to ‘Document View’.

  8. This will be a conversion specific separate view. Select the fields you like to see in the converted MS Word document in this view and design this Document View accordingly.

  9. Click FilePublish.

Creating the Workflow

  1. From the Library ribbon in MS SharePoint select Workflow Settings → Create a workflow in SharePoint Designer.

  2. Name the workflow whatever you like.

In this workflow you will need to set the value of the _MuhimbiViews field before carrying out the conversion. The workflow does not persist the value of the changed field before executing the conversion step, and so we need to ensure the values are updated accordingly before this step. You can do this in two ways:

Using an Impersonation Step

  1. Position the cursor before Step 1 and click Impersonation Step button in the ribbon.

  2. Position the cursor inside the Impersonation Step and add a ‘set field in current item’ action.

  3. ‘Use this action to set the value of the ‘_MuhimbiViews’ field to ’’DocView’.

  4. Position the cursor after the Impersonation Step and click Step button to add a new step.

  5. In this new step add the ‘Convert Document’ action and fill in the blanks.

  6. Publish the workflow and execute it on a previously filled out form.

The resulting MS Word document should contain DocView in MS Word document.

Using Pause for Duration

The steps below assume the default, empty workflow state and not the workflow entered as part of the previous use case.

  1. Position the cursor inside the first Step and add a ’set field in current item’ action.

  2. ‘Use this action to set the value of the ‘_MuhimbiViews’ field to ’’DocView’.

  3. Add the ‘Pause for duration’ action as the next step and let it pause for one minute .

  4. Add the ‘Convert Document’ action and fill in the blanks.

  5. Publish the workflow and execute it on a previously filled-out form.

It may take a while to execute due to the Pause action, but the resulting MS Word document should contain the DocView in MS Word format.

A third option exists, which is to specify Converter Specific Settings using the XML Override facility in the ‘Convert Document’ Workflow activity.

Note: When converting an InfoPath form to MS Word using any of the above methods, the software does not work in the same way as PDF. It can only convert one view specified to an MS Word document. If more than one view is specified in the Convert Document action, then the first view is only converted to an MS Word document.

image

From browser-based form (left) to PDF Document (right). Click here to open the entire PDF file.

Additional Resources

Knowledge Base Articles

  • Converting InfoPath / Nintex Forms List Items](/guides/document-converter/power-automate/knowledge-base/converting-infopath-nintex-forms-based-list-items-using-the-muhimbi-pdf-converter/)

  • Specifying which InfoPath view(s) to convert](/guides/document-converter/power-automate/knowledge-base/how-can-i-specify-which-infopath-view-s-to-convert/)

  • Working with InfoPath attachments](/guides/document-converter/power-automate/knowledge-base/how-does-the-pdf-converter-deal-with-infopath-attachments/)

  • Working with with InfoPath XSN files](/guides/document-converter/power-automate/knowledge-base/how-does-the-pdf-converter-deal-with-infopath-xsn-files/)

Troubleshooting Articles

  • CabLib Extract ERROR when converting InfoPath files](/guides/document-converter/sharepoint/troubleshooting/cablib-extract-error-when-converting-infopath-files/)

  • InfoPath cannot execute any view-related object model calls](/guides/document-converter/sharepoint/troubleshooting/infopath-cannot-execute-any-view-related-object-model-calls-the-view-is-not-ready/)

  • InfoPath Rules / Custom code / Data connections are not executed](/guides/document-converter/sharepoint/troubleshooting/infopath-rules-custom-code-data-connections-are-not-executed/)

  • Troubleshooting when InfoPath form fails to convert](/guides/document-converter/sharepoint/troubleshooting/my-infopath-form-fails-to-convert-how-can-i-troubleshoot-this/)

  • Word / Excel file does not look 100% the same](/guides/document-converter/sharepoint/troubleshooting/when-converting-infopath-to-word-excel-my-file-does-not-look-100-the-same/)

Blog articles

Information

We recently released the Muhimbi Document Converter Xtension for Nintex Automation Cloud. You can download it here or learn more about available Muhimbi deployments for Nintex on our product page.

Muhimbi Document Converter for SharePoint has the ability to control which view or views to convert to MS Word. It is even possible to specify which views to convert depending on the current status of the form.

The views to convert can be specified during design time, or at run time using a little bit of custom code or Nintex forms rules. You can also control which views to convert using Nintex workflow or Nintex for O365 in MS SharePoint Online. The example provided below uses the Nintex workflow. But this works equally well in the MS SharePoint Designer workflow as well.

Compared to creating similar conversions in MS SharePoint Designer, it has become much easier using Nintex Workflow, especially in combination with the Document Converter For SharePoint’s native Nintex support. In addition to the PDF Conversion Workflow Activity, there are also Nintex activities for PDF watermarking, PDF security, PDF merging, HTML to PDF conversion and more.

This section illustrates the power of these combined tools using an example that is usually quite tricky to achieve in MS SharePoint Designer Workflow: In this example, we create a workflow to retrieve all files modified during the current day and convert them to MS Word. Ideally, you would schedule this workflow to run off-peak to batch process all new and modified files.

nintex workflow

Nintex Dialog for the new Convert Document Action

The Nintex Convert Document Action can use Nintex Lookups and Workflow Variables and can be used to convert items other than the ones that triggered the workflow, which makes it ideal for converting entire sets of documents.

Prerequisites

Before we build the workflow, please ensure all prerequisites are in place. It is also assumed that the reader has some knowledge of building Workflows using Nintex Workflow.

  1. Make sure the Document Converter for SharePoint version 4.1 (or newer) is installed in line with chapter two of the included Administration Guide.

  2. Naturally Nintex Workflow will need to be installed as well. Nintex Workflow versions 2007, 2010 and 2013 are supported.

  3. Make sure the Muhimbi.PDFConverter.Nintex.WebApp SharePoint Feature is activated on the relevant Web Application using SharePoint Central Administration.

  4. You will need to have the appropriate privileges to create workflows.

Creating the Infopath Form

  1. Navigate to the MS SharePoint List where you want to design the Infopath form.

  2. Go to Site Settings → Form Options and click Customize the current form using Microsoft Infopath and click OK button.

    customize current form

  3. InfoPath Designer for the list opens

  4. On Page Design tab select New View.

  5. Name the new view ‘DocView’ or any name of your convenience.

  6. Change the Title at the top to ‘Doc View’ so you know the exact view that has been exported.

  7. Select the fields you like to see in this view and design the Form View accordingly.

  8. Click FilePublish.

Creating the Nintex Workflow

To get started, create a new workflow and choose the blank template. You can download the complete workflow in NWF format and reuse it for your environment.

finished nintex workflow

Make sure the workflow doesn’t start automatically and add the workflow variables listed in the following screenshot.

workflow variables

Please ensure that the appropriate data types are assigned (They are listed between round brackets behind each variable name). The names are largely self-describing, but some additional information is provided below:

  • Source Item ID: By default, the item that triggered the workflow is converted to MS Word document format. However, as we are iterating over multiple items, we need to specify the ID of the item to convert in this variable. In SharePoint 2010 / 2013 select Integer as the Type, not List Item ID.

  • Source List ID: The Document Converter assumes the item being converted is located in the same list the workflow is attached to. However, if this is not the case, then the ID (a GUID) of the list will need to be specified as well. In this example everything is located in the same list so this variable is not actually used.

  • Source Files: As we are potentially converting multiple files, we need to define a variable of type Collection to hold the list of files we will be iterating over.

  • Generated Doc Item ID: Once a file has been converted to MS Word document, you may want to carry out additional actions on this new file, for example checking it in. Once converted, the ID of the MS Word document is automatically stored in this variable. In SharePoint 2010 / 2013 select Integer as the Type, not List Item ID. This example uses the newer Convert Document activity, so please take into account that the Generated Doc Item ID is of type Text. If you wish to pass this ID into a secondary activity, you may need to convert it to the correct data type using the Convert Value Workflow Activity. An example can be found here. If you are using the (Legacy) Convert to PDF Workflow Activity, you can have data type Integer.

  • Generated Doc List ID: As the Document Converter allows files to be written to different document libraries, and even utterly different Site Collections, you may want to know the ID of the destination list.

Adding the workflow actions

We are now ready to add the actions to the workflow. Begin by adding a Query List action, allowing us to retrieve all files modified today and store the results in the Source Files collection

list action

You can fill out the settings for this action as in the screenshot listed above. You may want to add an additional filter rule to check that Content Type is not equal to Folder or Document Set.

Continue, by adding the For Each action to the workflow. Specify the name of the collection to iterate over and the name of the variable to store the Item’s ID in.

specify collection name

The next set of actions will all need to be added inside the For Each action, to make sure they are executed separately for each file in the list.

We want to make sure that we only invoke the Document Converter for files that are not already in Word document format. So, add a condition and check that the file type equals ‘docx’ as per the following screenshot:

file type equals xslx
Add the Convert document action listed under the Muhimbi PDF section to the No branch of the condition (type is not docx). Fill it out as per the image in the following screenshot.

convert document

Document Converter integrates with Nintex Workflow 2007, 2010 & 2019

Please ensure you enter the following override in the Content parameter of this action.

\<Override\>

\<ConversionSettings\>

\<ConverterSpecificSettings type="ConverterSpecificSettings_InfoPath"\>

\<ConversionViews\>

\<InfoPathView\>

\<Name\>INFOPATH_VIEW_NAME\</Name\>

\</InfoPathView\>

\</ConversionViews\>

\</ConverterSpecificSettings\>

\</ConversionSettings\>

\</Override\>

You may want to leave the Destination Path empty, which will write the MS Word document to the same location as the source file. For more information about the Destination Path or any of the other fields, hover the mouse over the small information icons.

The workflow is now done. You may want to add some tracking information using the Log In the History List action. In our example we use the following:

  • Last action in the No branch:
    List ID: {WorkflowVariable:Generated Doc List ID} - List Item ID: {WorkflowVariable:Generated Doc Item ID}

  • Last action in the Yes branch:
    Already in Doc Format: {WorkflowVariable:Source Item ID}

Running the Workflow

Finalize the workflow by saving and publishing it, after which it is ready to be executed.

You can either run the workflow manually or schedule it to run at a time of your choice..