Convert DOC to DOCX in SharePoint
In this guide you’ll learn how to convert DOC to DOCX or DOCX to DOC in SharePoint. The guide includes automatically converting DOC or DOCX formats using a SharePoint Designer Workflow or a Nintex Workflow.
Before you convert, you can review the following points of interest:
- It is now possible to convert from both DOC to DOCX and vice versa. Both steps are usually similar, except for changing the source and destination file format accordingly.
- It is even possible to ‘convert’ to the same format as the source, e.g. docx to docx, but specify additional settings such as a password on the document.
Converting MS Word DOC to DOCX format via MS SharePoint Workflow Designer
You can use the example below to create a simple workflow in MS SharePoint Designer, which converts MS Word DOC to DOCX format (or vice versa) as soon as it has been approved.
The legacy MS SharePoint 2007 / 2010 workflow engine is fully supported, as is the optional Workflow Manager that comes with MS SharePoint 2013 and later versions.
Before you start, ensure the Document Converter for SharePoint has been installed and you have access to a site collection with the appropriate rights to create workflows.
To convert MS Word documents from DOC to DOCX format (or vice versa) via a workflow using MS SharePoint Designer, you will need to configure the Document Library containing the MS Word documents and then also configure the workflow as per the details given below:
Create and Configure the Document Library Containing MS Word Documents
You can create and configure the Document Library containing MS Word documents by performing the following steps:
Create a Document Library named Proposal Documents. You can use any name of your choice.
Ensure you upload all the MS Word (DOC) documents you like to convert to this location.
Once created, navigate to the library’s Settings →
Document Library Settings → Versioning Settings screen and enable Requires content approval for submitted items.In the Document Library, create two folders (you can use any name of your choice): Confidential Proposals and
Approved Files.Note: If you are converting from DOCX to DOC, then the source MS Word (DOCX) documents need to be uploaded into this folder instead of MS Word (DOC) documents.
Create and Configure MS SharePoint Designer Workflow
You can create and configure the MS SharePoint Designer Workflow by performing the following steps:
Start MS SharePoint Designer and open the site collection that contains the Proposal Documents Document Library. This contains MS Word (DOC) Documents.
Click Add Item and select List Workflow. Specify the following settings:
Name for the workflow: Convert DOC to DOCX.
Select the Document Library associated with the Workflow: Proposal Documents.
When creating a SharePoint Designer Workflow in SharePoint 2013 or later, select the appropriate Platform Type.
Click Create button to proceed.
We are now ready to create the workflow. From the ‘Conditions’ menu, select the ‘If value equals value’ condition.
Click the first value followed by the display data binding (fx) button.
Select ‘Current Item’ as the Source and select ‘Approval Status’ in the field.
Click the OK button to continue.Click the second value and select ‘Approved’ from the list.
To avoid the same workflow being executed on the converted MS Word (DOCX) file after the conversion has taken place, we need to specifically exclude the MS Word (DOCX) files as follows:
- Add another ‘If value equals value’ condition.
- Click the first value followed by the display data binding (fx) button.
- Select ‘Current Item’ as the Source and select ‘File Type’ in the Field. Click the OK button to continue.
- Select ‘equals’ and change it to ‘not equals’.
- Click the second ‘value’ and enter ‘DOCX’, without a period ‘.’.
With the Conditions in place, we can now add the Actions, which is where the magic happens.
From the Actions menu, select Convert Document. It may be hidden behind the PDF option.
The following action is inserted:
Convert ‘this document’ to ‘this file’ as a ‘select file type’ , optionally use ‘this xsn or pdf’ as template, ‘include / exclude’ meta data and use ‘these optional parameters’. Store the converted item details in List ID: ‘Variable: List ID1’ , Item ID: ‘Variable: List Item ID1'Let’s examine what the various options within the action mean:
this document: Specify which document to convert. Select the option
and make sure Current Item is selected.this file: Specify the location to which the converted file will be written. The following options are available:
- Leave it empty: When no value is specified then, the converted MS Word (DOCX) document is written to the same folder as the source file.
- Site Relative URL: By specifying a URL relative to the current site, e.g. subsite/shared documents/DOC Files, any folder location in the current site collection can be targeted. This is the option we want to use so enter ‘Proposal Documents/Approved Files’.
- Web Application relative URL: Using a URL that is relative to the entire web application, e.g. /sites/Press Office/Public Documents/To Distribute, any folder location in any site collection can be targeted.
select file type: Select the file type you want the file to be converted to.
this xsn or pdf: If you want to specify a template, you can specify a xsn or pdf template. The following options are available:
- Leave it empty: When no value is specified then no template is used.
- Template from a Site Relative URL: By specifying a URL to the template relative to the current site, e.g. subsite/shared documents/template.pdf.
- Template from a Web Application relative URL: Using a URL to the template that is relative to the entire web application, e.g. /sites/Press Office/Public Documents/template.xsn
include / exclude metadata: In case of sensitive documents, we may want to strip out any custom SharePoint columns information from the file. Assuming that our document library contains a column Yearly sales forecast, and the MS Word document uploaded has information entered in that column, we want to select ‘Exclude’.
these optional parameters: You can add many additional parameters for the conversion document here.
Variable: List ID: A new workflow variable named List ID is automatically created. After the file has been converted, this variable will contain the ID of the list the converted file was saved to. This can later be fed into another action in order to manipulate this file further.
Variable: List Item ID: A new workflow variable named ‘List Item ID’ is automatically created. After the file has been converted, this variable will contain the ID of the item the converted file was saved to. This can later be fed into another action to manipulate this file further.
Insert a new action named ‘Log to History List’ and enter ‘File converted’.
Insert a new action named ‘Update List Item’ and select ‘this list’. We are now going to automatically mark the converted DOCX file as ‘approved’.
- From the ‘List’ dropdown select ‘Confidential Proposals’.
- Click Add button and set the field to ‘Approval Status’ and the value to ‘Approved’, and click OK.
Note: Starting with MS SharePoint 2010, it is no longer possible to set the value of the ‘Approved’ field. - In the ‘Find the List Item’ area set the field to ‘ID’.
- Click the fx button next to ‘Value’, specify ‘Workflow Variables and Parameters’ as the Source and set the field to ‘Variable: List Item ID’ and click the OK button.
- Click OK again to return to the MS SharePoint Designer Workflow. It should look like the image below:
Click Publish button to deploy and activate the workflow.
Testing the Workflow
You can test the workflow created by performing the following steps:
- Create or upload a document in MS Word (DOC) file format to the ‘Confidential Proposals’ folder.
- From the context menu, select Approve / Reject and approve the file.
This will automatically start the workflow, and after a few seconds, the Workflow status should change to Completed, as shown in the screenshot below.
Once the workflow has been completed, you will find the DOCX version of the MS Word document in the ‘Approved Files’ folder.
If an error occurs during the execution of the workflow, you can perform the following to troubleshoot the same:
- Check the messages on the workflow status screen.
- Check for errors in the Windows Event log.
- Check for errors in the SharePoint trace log.
Converting MS Word Documents from DOC to DOCX using Nintex Workflow
The Muhimbi Document Converter for SharePoint comes with comprehensive support for all Nintex Workflow versions, currently NW2007 – NW2019. It can easily convert MS Word documents from one format to another (DOC to DOCX). In this example, a Nintex workflow retrieves all the MS Word documents in DOC format modified during the current day and converts them to DOCX. In an ideal setup, you will schedule this workflow to run out of office hours to process this as a batch for all new and modified files.
To create a new workflow, you can follow the instructions below or download the complete workflow in NWF format from the following link:
Nintex Workflow to retrieve and convert files to PDF(opens in a new tab)
Prerequisites
Before we start building the workflow, ensure all prerequisites are in place. It is also assumed that the reader has some knowledge of building Workflows using Nintex Workflow.
- Ensure the Document Converter for SharePoint(opens in a new tab) version 4.1 (or newer) is installed in line with chapter two of the Administration Guide.
- Naturally, Nintex Workflow will need to be installed as well.
- Make sure the Muhimbi.PDFConverter.Nintex.WebApp SharePoint Feature is activated on the relevant Web Application using SharePoint Central Administration.
- You will need to have the appropriate privileges to create workflows.
Creating a new workflow
To get started, create a new workflow and choose the blank template. Ensure the workflow doesn’t start automatically, and add the workflow variables listed in the following screenshot.
Ensure that the appropriate data types are assigned. They are listed under the ‘Type’ column beside each variable name. The names are largely self-explanatory, but some additional information is provided below:
- Source Item ID: By default, the item that triggered the workflow is converted to DOCX 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 and later 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 also need to be specified. 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 DOCX Item ID: Once a file has been converted to DOCX, you may want to carry out additional actions on this new file. For example, check it in. Once converted, the ID of the DOCX is automatically stored in this variable. In SharePoint 2010 and later, select Integer as the Type, not List Item ID.
- Generated DOCX 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
You are now ready to add the actions to the workflow. You can start by adding a Query List action, allowing you to retrieve all files modified today and store the results in the Source Files collection.
You can fill out the settings for this action as per the screenshot above. You may want to add a filter rule to check that Content Type is not equal to Folder or Document Set.
You can continue by adding the For Each action to the workflow. Specify the collection’s name to iterate over and the variable’s name to store the Item’s ID.
The next set of actions you add will need to be added inside the For Each action to ensure they are executed separately for each file in the list.
You need to ensure that the workflow only invokes the Document Converter for those files that are not already in DOCX format. To achieve this, add a condition and check that the file type equals ‘docx’ as per the following screenshot.
After this, you need to add the Convert document action listed under the Muhimbi PDF section to the No branch of the workflow condition (as we want this workflow to only convert those files that are not of type docx). You can fill this section as per the image below:
The Document Converter integrates with all Nintex Workflow versions.
You may want to leave the Destination Path empty, which will write the DOCX File to the exact location as the source file. Hover the mouse over the small information icons for more information about the Destination Path or any other fields.
The workflow is now done. You may want to add some logging information using the Log In the History List action. In our example, we use the following two logging information:
- Last action in the No branch:
List ID: {WorkflowVariable:Generated DOCX List ID} - List Item ID: {WorkflowVariable:Generated DOCX Item ID} - Last action in the Yes branch:
Already in DOCX Format: {WorkflowVariable:Source Item ID}
Running the workflow
You can finalize the workflow by saving and publishing it, after which the workflow is ready to be executed. You can either run the workflow manually or schedule it to run at a specific time of your choice.
Other Operations
This section demonstrated how to invoke the Convert action on Muhimbi's REST interface to convert MS Word documents in DOC format to DOCX. In addition to DOCX Conversion, we also expose additional end-points for Merge, Watermark, Secure, Split, OCR and also for Copy Metadata operations. Full examples are beyond the scope of this article, but you can find examples in the SharePoint section of our GitHub repository(opens in a new tab).