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:
Create a console application:
- Open Visual Studio 2010.
- Go to File => New => Project.
- Select the Console Application template and enter the Name.
- Click Ok.
- Add a reference to the Microsoft.Office.Word.Server assembly(C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\ Microsoft.Office.Word.Server.dll)
- Open Program.cs file and replace the code with the following one.
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 the .doc document is added to the Shared Documents.


Join the conversation! Your thoughts help the community grow.