Friday, May 20, 2011

Word automation services – Part 2

Here we are with part 2 of word automation service. If you have not gone through the Part 1, then I would recommend you reading part 1 first and then return to this post for further reading.

We now know about the fantastic feature called word automation service. Now it’s not just that you can do it with the help of code.

If you are a server administrator, then again PowerShell is here to help you out with this. PowerShell is undoubtedly one of the best enhancements that have come with SharePoint 2010 which gives more power than traditional stsadm command for sure.


So open up the Start menu - >Administrative Toos -> Windows PowerShell Module.

We are using the same library that we have used in Part 1.

Now start writing following commands one after the other and see the magic. Again remember you need to wait for some time depends on the source file format and destination file format to get the output.

PowerShell also provides you way to check the status of the process the same way we checked with the code in part 1.

First we need to take the proxy reference of the word automation service. But yes, make sure that word automation service should be running.





Now we will take the reference of the site



Now we need to set the input and output folder. It means source library path and destination library path. I am going to have it both at the same place.



Now we will take the reference of conversion job we created in first step, set up the user token under which the job will run, output format and should we override the file if already there or not.



Now then once we configure all these, it’s time to start the job to convert.

So your overall code would look something like this



At the same time, we can query the conversion status as well.




As you can see it shows the status, you can keep checking the status. After process started, it will be number of documents in progress and at the end if you query, it will be number of documents completed.

Default time is 15 minutes. You need to wait till 15 minutes, but if you do not want to wait till 15 minute then you can force job to run.



and Here is the output. If you have multiple files, it will automatically take all files and convert them to PDF.

2 comments:

Santhosh said...

we can even reset the 15min schedule to 1 min by using power shell command
Get-SPTimerJob | Where-Object {$_.Displayname -eq "Word Automation Services Timer Job"}

$NewSchedule = new-object Microsoft.SharePoint.SPMinuteSchedule
$NewSchedule.Interval = 1

$job.Schedule = $NewSchedule

$job.Update()

Santhosh said...

The timer job can be set to 1 min schedule by using the powershell command below :
Get-SPTimerJob | Where-Object {$_.Displayname -eq "Word Automation Services Timer Job"}

$NewSchedule = new-object Microsoft.SharePoint.SPMinuteSchedule
$NewSchedule.Interval = 1

$job.Schedule = $NewSchedule

$job.Update()




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com