Archive for August, 2010

Author: Tobias Zimmergren | | @zimmergren 


In SharePoint 2010, there is a new Service Application called Word Automation Services. This Service Application is used to convert documents from Word to different formats.

Word Automation Services can open about the same formats as Windows Word 2010 can:

  • Filetypes it can open include:
    .docx, .docm, .dotx, .dotm, .doc, .dot, .rtf, .mht, .mhtml, .xml (Word xml)

  • Filetypes it can save as include:
    .docx, .docm, .dotx, .dotm, .doc, .dot, .rtf, .mht, .mhtml, .xml (Word xml), PDF, XPS

In this article you’ll see an example of how you can utilize the Word Automation Services in order to build a custom solution that takes care of converting documents (as listed above) into PDF documents.

Programmatically work with Word Automation Services in SP 2010

Note: You cannot deploy a solution working with the API’s in the Word Automation Services in the Sandbox. Rather you’ll need to target your application as a Farm Solution.

There’s not really a whole lot to it. Just follow along with these few steps and you’ll be fine!

In the API for Word Automation Services you’ll find a few different ways to convert documents including:

In the following example I’ll demonstrate how to use the AddLibrary() method in order to convert the contents of an entire document library into PDF documents! (Yes, that is way awesome)

1. Add the Word Automation Services API reference to your project

The following reference needs to be added to your project:

It can be found here:

2. Add the proper using-statements

 using  Microsoft.Office.Word.Server.Service;
 using  Microsoft.Office.Word.Server.Conversions;

3. Create a job to convert an entire Document Library to PDF’s

First, fetch the WordServiceApplicationProxy object (so we don’t have to hard-code the service app name..). This first line requires the Word Automation Service Application to be added to the default proxy group.

Second, we instantiate a new ConversionJob class and shoots in your WordServiceApplicationProxy as a parameter:

 var  wordAutomationProxy = 
     (WordServiceApplicationProxy )
     SPServiceContext .Current.GetDefaultProxy(typeof  (WordServiceApplicationProxy ));
 var  conversionJob = new  ConversionJob (wordAutomationProxy);

Next we need to specify a UserToken for the job to tell the job under what credentials to run.
We also need to specify a
name for the job.
Finally you can add whatever
Settings you want for your job, I’ve chosen that I want my files to be output as PDF’s.

 conversionJob.UserToken = SPContext .Current.Web.CurrentUser.UserToken;
 conversionJob.Name = "Zimmergren.SP2010.WordAutomationDemo Conversion Job" ;
 conversionJob.Settings.OutputFormat = SaveFormat .PDF;

Next we will simply specify a library where the original .doc or .docx files reside and point out the destination library like this, and start the job by adding it to the timer job queue:

 conversionJob.AddLibrary(origLib, destinationLib);

This is the sample code in one snippet

 protected  void  btnConvert_Click(object  sender, EventArgs  e)
         SPList  origLib = SPContext .Current.Web.Lists[ddlLibraries.SelectedValue];
         SPList  destinationLib = SPContext .Current.Web.Lists["PDFLibrary" ];

         var  wordAutomationProxy = 
             (WordServiceApplicationProxy )
             SPServiceContext .Current.GetDefaultProxy(typeof  (WordServiceApplicationProxy ));
         var  conversionJob = new  ConversionJob (wordAutomationProxy);

         conversionJob.UserToken = SPContext .Current.Web.CurrentUser.UserToken;
         conversionJob.Name = "Zimmergren.SP2010.WordAutomationDemo Conversion Job" ;
         conversionJob.Settings.OutputFormat = SaveFormat .PDF;

         conversionJob.AddLibrary(origLib, destinationLib);

         Label1.Text = "Conversion job started!" ;
         Label1.Visible = true ;
     catch (Exception  ex)
         Label1.Visible = true ;
         Label1.Text = "Error:<br/>" ;
         Label1.Text += ex.Message;

So what’s the results?

When you’ve created a new ConversionJob, it’ll be added to the Timer Job schedule to be run by SharePoint. When the job has been run, it can look like this:

Original Document Library, filled with some Word documents:

These files will then be converted to PDF’s and put into my PDFLibrary like this:


To get started with the Word Automation Services, you don’t really need to do a lot of coding. Just specify the references, hook up a reference to your service app and create a new ConversionJob and you’re up and running.

This article demonstrated how to convert an entire library of documents to PDF’s with a single click.

Awesome. Enjoy!

Author: Tobias Zimmergren | | @zimmergren


One of the coolest new set of functionality for SharePoint 2010 is the Taxonomies (Term Store, Term Sets, Terms) that you can easily create using the amazing Managed Metadata Manager service application.

In this article I’ll talk briefly about how you can utilize the SharePoint API to programmatically work with Taxonomies and create terms and fetch the terms in your term store. This should give you some nice ideas on how to get going!

A simple example of a taxonomy

Let’s say we’ve got a taxonomy worked out and implemented in SharePoint. It could look something like this (I’m using some made up samples below):


So, if you’ve got a taxonomy configured in your Managed Metadata Service Application, you can work with those programmatically – and that’s what this little tip is about.

Work with the taxonomy API’s programmatically in SP 2010

In this article I will talk about some of the basics to get started with taxonomies in SharePoint 2010 programmatically. First, of course, we need to create a new project and add the references for the Taxonomy API.

Preparing for development

First of all, create a new project (In my case, I chose to create a Visual Web Part project).

You’ll need to add the following reference to your project:


You’ll find this reference here:
C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14ISAPIMicrosoft.SharePoint.Taxonomy.dll


So, the first thing we would like to do is to learn how we can read the taxonomies we’ve got in our store. To do this, we utilize Microsoft.SharePoint.Taxonomy.

There’s a few good-to-know classes in this namespace that we’re going to work with:

The above classes are stated in their hierarchically correct order, meaning means that you start out with the TaxonomySession which contains the TermStore, which contains the Groups.. and so on.

Reading the Metadata store (Managed Metadata Service) programmatically

Sample code from my Visual Web Part’s user control (I have a control called tvMetadataTree in the user control):

     public  partial  class  TaxonomyWebPartUserControl  : UserControl 
         protected  void  Page_Load(object  sender, EventArgs  e)
             SPSite  thisSite = SPContext .Current.Site;
             TaxonomySession  session = new  TaxonomySession (thisSite);

             TreeNode  treeNode = new  TreeNode ();
             treeNode.Text = "Metadata Awesomeness" ;

             foreach (TermStore  termStore in  session.TermStores)
                 var  tsNode = new  TreeNode (termStore.Name, null , null , "" , null );
                 //treeNode = tsNode; 

                 foreach (Group  group in  termStore.Groups)
                     var  node = new  TreeNode (group.Name, null , null , "" , null );
                     //treeNode = node; 
                     foreach (TermSet  termSet in  group.TermSets)
                         node = new  TreeNode (termSet.Name, null , null , "" , null );
                         treeNode = node;

                         foreach (Term  term in  termSet.Terms)
                             AddTermSet(term, treeNode);

         void  AddTermSet(Term  term, TreeNode  treeNode)
             var  node = new  TreeNode (term.Name, null , null , "" , null );
             treeNode = node;

             foreach  (Term  t in  term.Terms)
                 AddTermSet(t, treeNode);

The end result will be a simple TreeView control filled with the Metadata structure from the store, looking something like this:


That’s about what you would need to get started with this!


Alright, so I wrote this small article up due to some students asked me for some taxonomy sample code a while back. I hope everyone enjoys this tip on how to programmatically work with the Taxonomies in SharePoint Server 2010!

As always, enjoy!

A free MSDN Ultimate subscription goes to Anders Rask

August 13th, 2010 by Tobias Zimmergren

Author: Tobias Zimmergren | | @zimmergren


Two weeks ago I posted in the blog about giving out some free MSDN Ultimate subscriptions with VS 2010 to anyone who provided me with a valid enough reason to get them.

One of the first few people who sent me an e-mail was Anders Rask, a Danish SharePoint consultant with an expressed love for SharePoint and related technologies. I was waiting for 2 weeks to see if I got some more valid reasons – and I did. Almost 100 people sent an e-mail providing different reasons for getting a MSDN license.

As I mentioned in my first post it is “first come – first served” that applies.

Here’s Anders reasoning

Here’s the quote from Anders for getting the free MSDN subscription:

I would love to get the license!

I work with SharePoint 24/7 and am active in the SharePoint community in various ways like:
- SharePoint Overflow
- My Blog:
- Twitter: @andersrask.

However I cannot convince my employer to give me my own license for home use. I got 8 farms on my test rig at home all with expired licenses that i can’t use anymore.

I come from a developer background, but are trying hard to learn as much as I can about configuring and provisioning farms, so it’s a real pain that my rigs keep expiring so I have to reinstall..


Short in short, congratulations Anders Rask – and thank you for being active in the SharePoint community!

CKS : Developer Tools – A tool for your toolbox

August 11th, 2010 by Tobias Zimmergren

Author: Tobias Zimmergren | | @zimmergren


If you’re a seasoned SharePoint developer, you probably have a good set of tools that you’re working with on a daily basis. Some of my all-time favorites include:

With the addition of new tools to the community basically every week, it could be hard to keep track of all the different extra applications you’d want to use.

CKS:Dev has been released!

If you’ve heard of CKS before (Community Kit for SharePoint), you might know that there’s great support for Blogs (EBE) and other cool things. Actually, this blog is based on the CKS:EBE code. Works like a charm!

Now, if you’ve missed it – there’s a new addition to the CKS-family called the CKS: Developer Tools which is essentially extending the functionality in Visual Studio 2010.

There’s currently two versions released. One for SharePoint Foundation 2010 and one for SharePoint Server 2010.

You can find them here:

What’s in it for me (the developer)?

There’s some really superb additions to Visual Studio 2010 when installing the aforementioned versions of the CKS:Dev project. These include some of my favorites:

  • SharePoint Tab in the References dialog (no need to goof around the filesystem to find the dll’s)
  • Extended SharePoint Explorer
    • See more libraries
    • Activate/Deactivate features directly from the explorer
    • Enable/Disable the Developer Dashboard (yay!)
    • Generate Entity Classes (finally!)
    • <a lot more, but those were my favorites>
  • A bunch of new cool project templates, including some of these jolly good jewels:
    • Basic page
    • Delegate control
    • Master page
    • Custom Action, Custom Action Group, Hide Custom Action (good stuff)
    • Sandbox Full Trust Proxy
    • <the list continues..>
  • Quick Deployment steps
    • Easily deploy your code and files quickly with the WSPBuilder-alike commands like:
      • “Copy to SharePointRoot”
      • “Copy to Bin”
      • “Copy to GAC”
      • “Recycle App Pools”
      • “Attach to worker process”
      • and so on.

Aside from the aforementioned awesomeness, there’s a whole lot of other stuff that I bet I’ve missed out on with this tool. I’d say go and find out yourself if you haven’t already – you  will not want to work without this in your toolset ever again, of that you can be sure!


The reason for posting some info and selling-points behind the (free) developer tools from the CKS team are foremost that when I’m doing training or when I’m supporting clients in different projects, they always asks me what tools they should have in their toolbox.

I’m surprised that not even 20% of them knows about the CKS:Dev extensions. So with this post I’m hoping to enlighten some of those folks.


MCPD: SharePoint track

August 11th, 2010 by Tobias Zimmergren

Author: Tobias Zimmergren | | @zimmergren



The SharePoint 2010 exams are final and has been released so you can head over to your local training center and take the exams when you feel ready for it.

I recently passed both the TS and the PRO exams for SharePoint 2010 Development, and I ought to give you a glimpse about what they’re all about, and where to find more information.

Two certifications to become MCPD: SharePoint

Exam 70-573 – TS: Microsoft SharePoint 2010, Application Development

This is the first exam in the series of two, and is the easiest one to pass as well. Quoted from the Microsoft-site about the exam:

A Microsoft Certified Technology Specialist (MCTS) in Microsoft SharePoint 2010, Application Development should be able to perform the following tasks:

- Write code that extends SharePoint 2010
- Add and support code to an existing project
- Write code for and test custom features in a SharePoint solution such as a Visual  Web Part or Event Receiver
- Implement a solution designed by lead SharePoint Developer
- The candidate should also have the following experience:

Exam 70-576 – PRO: Designing and Developing Microsoft SharePoint 2010 Applications

This is the second and final exam in the developer series, and differentiates from the other exam in that way that it covers more stuff about solutions deployments and strategies. Quoted from the Microsoft-site about the exam:

The candidate is responsible for designing custom code for projects that are deployed to SharePoint servers. This includes technology selection across the many ways to build code in SharePoint, ensuring the team development environment is configured, creating a strategy for code deployment, versioning, configuration, or structure.
The candidate also leads a team of SharePoint developers, has at least two years of SharePoint development experience, has at least three years of ASP.NET development experience


You can get all the information you want about the exams by going to the two following pages respectively:

Book: SharePoint 2010 Web Parts in Action

August 1st, 2010 by Tobias Zimmergren

Author: Tobias Zimmergren | | @zimmergren


As you might know there’s a whole lot of SharePoint 2010 books coming out quite soon, and some have already been released to the market.

In this article I will highlight one of the books I like in particular, the SharePoint 2010 Web Parts in Action by my good friend Wictor Wilén published by Manning.

As a Technical Reviewer for this book, I’ve been able to read it through and give feedback on it to the publishers and author. This is not a technical review though, this is just my expressed opinion on the book.

Book coverage

This is a developer-focused book, covering a lot of the aspects that you (the developer) needs to get a grip on. If would think this book suits both SharePoint-beginners as it will suit people moving from SharePoint 2007 to SharePoint 2010. However, I would recommend that you have a basic understanding of .NET and C# and how ASP.NET works before digging too deep into SharePoint development – after all, SharePoint builds on top of these technologies :-)

The book consists of three main parts:

  • Part 1: Getting Started
    • Introducing SharePoint 2010 Web Parts
    • Using and configuring Web Parts in SharePoint 2010
  • Part 2: Developing SharePoint Web Parts
    • Building Web Parts with Visual Studio 2010
    • Building the user interface
    • Making Web Parts customizable
    • Web Part Resources and Localization
    • Packaging, deployment and security
    • Troubleshooting Web Parts
    • Web Part caching
    • Dynamic Web Parts
    • External application Web Parts
    • Mobility
    • Web Part design patterns
  • Part 3: Dashboards and Connections
    • Connecting Web Parts
    • Building dashboards

This book will walk you through topics from the basic understanding of Web Parts in SharePoint 2010 to more advanced topics like Web Part design patterns, connectable web parts and building dashboards.

Who should get this book?

So why would someone get this book, you might ask.

First of all, I’m getting it myself – because it’s a great reference to have when you’re a SharePoint developer, that’s for sure!

Part from my (slightly subjective) opinion as to why I would get it, you might want to get it because the following reasons:

  • Pedagogical
  • Good and thorough coverage of the topics
  • Code samples
  • Written by an experienced developer who knows the common problems you might run into