ARTICLE

How to convert docx to doc document in SharePoint 2010 using Word Automation Services

Posted by Vijai Anand Articles | SharePoint 2010 December 27, 2010
In this article we will be seeing how to convert .docx document to .doc document in SharePoint 2010.
Reader Level:


In this article we will be seeing how to convert .docx document to .doc document in SharePoint 2010.

Word Automation Services is a new feature available in SharePoint 2010. It supports converting Word documents to other formats.

This article describes the following steps to show how to call the Word Automation Services to convert a document:

  • Add a word document to the SharePoint Shared Documents.
  • Create a console Application.
  • Add a reference to the Microsoft.Office.Word.Server assembly.

Add a word document in the Shared Documents:
share1.gif

Create a console application:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Word.Server.Conversions;
using Microsoft.SharePoint;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {                 
            using (SPSite spSite = new SPSite( "http://servername:4040/"))
            {  
           //Defines a collection of settings for all conversions within a single conversion job.

                   ConversionJobSettings jobSettings=new ConversionJobSettings();
                jobSettings.OutputFormat = SaveFormat.Document97;
           //Represents a collection of file conversions (of single files or entire libraries) that share a common set of conversion properties and are logically tracked as a single unit.
                ConversionJob pdfConversion = new ConversionJob("Word Automation Services", jobSettings);
                // Set the credentials to use when running the conversion job.
                pdfConversion.UserToken = spSite.UserToken;
                pdfConversion.AddFile("http://servername:4040/Shared%20Documents/ExternalList.docx",
                    "http://servername:4040/Shared%20Documents/ExternalList.doc");
                pdfConversion.Start();
            }
        }
    }
}

  • Build the solution and hit F5.

  • After a few minutes you will see that a .doc document is added to the Shared Documents.

    share2.gif

Login to add your contents and source code to this article
post comment
     

You can use web based document converters like Saaaspose.Words (http://saaspose.com/api/words) it not only converts docx files to doc and vice versa but also allows you to convert your word document to many other formats and also you can create your document from scratch.

Posted by zarfishan zahid Nov 01, 2012
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter