I’ve just published the first release for a CodePlex project I started to provide sample projects / solutions for using the Word Automation Services in SharePoint 2010.
Word Automation Services allow you to convert document to and from different formats.
File formats the service can read:
- Office Open XML (DOCX, DOCM, DOTX, DOTM)
- Word 97-2003 Document (DOC) and Word 97-2003 Template (DOT)
- Rich Text Format (RTF)
- Single File Web Page (MHTML)
- HTML
- Word 2003 XML
- Word 2007/2010 XML
File formats the service can write:
- XPS
- Office Open XML (DOCX, DOCM)
- Word 97-2003 Document (DOC)
- Rich Text Format (RTF)
- Single File Web Page (MHTML)
- Word 2007/2010 XML
(source)
As far as I’ve found out, there are no UI features available out-of-the-box to use these services, so I’ve decided to create some. The first one is a custom workflow action you can use in SharePoint Designer to convert a document to many of the supported
formats.
In the workflow designer you can add the “Convert Document” action:
The action is inserted into the workflow step where you can specify the url of the output file, select the output format and save options and select a variable for storing the conversion job id (which you can use later to retrieve the status, as the job runs asynchronous):
The job id is also logged into the Workflo w History Log (the second entry is from a second workflow action that logs the returned conversion job id variable):
After the job has run, which can take up to a few minutes (depending on the word automation services settings), the converted document appears in the library:
The custom workflow action is one of the first features for Word Automation in SharePoint 2010 I’ve planned to release. Other features will be a Ribbon and Item context menu extension and more Workflow actions.
Let me know if you have any suggestions for improvement or other functionality you would like to see.
Related posts:















18 Comments
hi peter,
Nice artcile and great solution.
I’m using your sharepoint solutions to convert documents to pdf through workflow. I have created the workflow with convert document action and added output document url but its not working. please help how to set the appropirate output document url with examples.
You will need to use the full url to the outputfile.
The workflow action will simply call the following method:
http://msdn.microsoft.com/en-us/library/microsoft.office.word.server.conversions.conversionjob.addfile.aspx
I got the following error when i tried to activate the solution to my sharepoint server
This solution contains invalid markup or elements that cannot be deployed as part of a sandboxed solution. Solution manifest for solution ’8a318b41-0260-49c9-a627-4fe83ad052d8′ failed validation, file manifest.xml, line 6, character 4: The element ‘Solution’ in namespace ‘http://schemas.microsoft.com/sharepoint/‘ has invalid child element ‘TemplateFiles’ in namespace ‘http://schemas.microsoft.com/sharepoint/'. List of possible elements expected: ‘FeatureManifests, ActivationDependencies’ in namespace ‘http://schemas.microsoft.com/sharepoint/'.
Troubleshoot issues with Microsoft SharePoint Foundation.
That’s because this solution is not supported as a sandbox solution. It needs to deploy files to the _layouts folder.
So helpful – thanks for publishing this! Now that MOSS 2010 is taking off, this will be really, really helpful (we’re going to test and deploy).
One addition that would be cool is a workflow that, instead of writing to a library, would send by e-mail, or simply activate a download… e.g., “Download as .Doc” or “Download as .DocX” to help the people who don’t have newer versions of MSWord software…
Anyway — great work, thanks again!
–DC
Thanks so much for all you’ve done to put these this together! I’ve got everything working as it should but I’m having trouble with the output URL. I’ve tried /folder, http://site/folder, folder, etc…and everything returns an error. Am I missing something?
Thanks in advance!
Mike
You will need to specify the full url, including the filename and extension.
Have everything implemented. For some reason, on the screen where I can choose the format and the destination, this screen will always come back, once I click OK.
What I`m doing wrong ?
Hi Guys,
I am trying to convert infopath form into pdf format.
I think I have done everything but still not getting the output file. For you understanding, I will put the steps I have done:
On clicking the workflow status to check workflow information to check whats happening, it shows
1) I have used SP2010WordAutomation.Workflow.wsp.
2) I published infopath form to a forms library in SP 2010 site
3) I opened up my sharepoint 2010 designer and created a reusable workflow with content type.
4) I used following action from SP 2010 designer,
Convert documents in library with url http://servername/formlib, using outputformat PDF, store the documents in library with url http://servername/pdflib and place the job id in variable: conversion job id3; if the document already exists “Always overwrite”
5) Once this is done I publish the workflow….
6) Then I go to library http://servername/formlib where my infopath forms can be added using “Add Document”.
7) When I add one form document – The status of the workflow column changes to “In Progress” then after some time it changes to “Completed”.
Conversion Job with Id= some id started. Under outcome heaer there is nothing
9) But when I go to library http://servername/pdflib, I dont get the converted file.
Can somebody please tell me what am I missing.
Thanks for you valuable time.
Thanks,
Nirav.
niravsakhi@hotmail.com
InfoPath is not a valid input format for Word Automation services. You can see this in the list in the top of this post.
Peter
Peter,
Thanks for that. Do you have any option where I can do research for this requirment.
Thanks,
Nirav.
Hi, sorry, but, I download de .wsp file, but how I can use it? I don´t known how import it to my Sharepoint Server, or how to use this file, please, help me with some tips. Thanks and great work Peter!
I cannot get this to activate unless I activate the “Microsoft SharePoint Foundation Sandboxed Code Service”. When I do that, it gives me the same error as above. What services do I need active to activate this solution? FYI – I’m a newbie
Hi Peter,
I was wondering if you have a copy list item activity that will use “append to version history…”.
I have the need for it, my situation is: Document needs to be moved/copied from one list to another, but append to version history. then the document needs to be deleted. the OOTB has a copy, which overwrites everything, I just need it append to the version history.
If you have it, please let me know.
Thanks in advance
Chris.
This is great, thanks. Though, I’m running into a workflow issue. I’m using your activity in a workflow in library A to convert a doc to a pdf which lands in library B. I have another workflow in library B that is set to start for every new item. This workflow generates a “failed on start message” for the inbound pdfs. To be clear:
1. manually running the workflow in library B: works fine
2. uploading a doc (which therefore triggers the workflow) in library B: works fine
3. Using word automation services via your activity to generate a pdf in library B: The workflow in library B throws an error. (failed on start)
The workflow in library B has one action: log to history list.
Any thoughts?
Hi Peter,
Overall your solution has worked for me. However, I’ve run into a couple scenarios (2 server environments out of 5) where the solution suddenly stops working and i have to go into the workflow and remove then readd the line to “Convert Current Document…”. Then it works again. Have you experienced this issue and do you have any advice for what might be happening? There were no changes to Word Automation services and no Sharepoint updates applied when it happened.
thanks!
Hi Steph,
I haven’t used the solution in a lot of production scenarios for very long, so I’ve got no experiences with this happening.
My first guess would be that the code is somewhat buggy and might contain some memory leaks, which causes the workflow action to stop working.
Peter
Hi
I’ve installed from codeplex OK and I can see the workflow actions in the workflow list. But if I pick one nothing happens – doesn’t appear in my workflow – any ideas? (using SP2010 Server Enterprise with one WFE and one APP Server)
Thanks
One Trackback
[...] Dit blogartikel was vermeld op Twitter door PB Coleman en Gert Lambers, Gert Lambers. Gert Lambers heeft gezegd: #Word #automation services in #sharepoint. Very interesting post of Peter Gerritsen how to implement! http://ow.ly/2y4jH [...]