Open XML Programming Lab

Version: 3.0.0

Description

Now with both C# and VB code samples! In this lab you will create a SharePoint event handler that will automatically mark an Open XML document as finalized when its status has changed to completed. This is a common practice in the final steps of a workflow or other process that is intended to move the document through a specific lifecycle.

Overview

In this lab exercise, you will build a small add-in for Word 2010. You will make use of the data-binding capabilities of WPF combined with the SharePoint Client API. You will make use of new C#/VB language features to make calls into the object model easier.

Objectives

In this lab you will:

  • Learn to manipulate an OpenXML document using the Open XML SDK
  • Learn to build a SharePoint 2010 List Event Handler

System Requirements

This lab assumes that you have SharePoint Server installed in a test environment. For guidance on how to setup SharePoint Server see https://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx. Note that any URL referred to in this lab must be adjusted for use with your local setup. You must have the following items to complete this lab:

  • Microsoft® Windows® Vista SP1 or Microsoft® Windows Server 2008 (64-bit)
  • Microsoft® SharePoint Server 2010 (64-bit)
  • Microsoft® Office Professional Plus 2010 (32-bit or 64-bit)
  • Microsoft® Visual Studio 2010

Setup

You must perform the following steps to prepare your computer for this lab. This consists primarily of creating a SharePoint site collection at https://intranet.contoso.com/sites/OpenXML and installing the code snippets for this lab.

  1. Run the command file Setup.bat located at %Office2010DeveloperTrainingKitPath%\Labs\OpenXML\Source\.

Exercises

This Hands-On Lab is comprised of one exercise with the following tasks:

  1. Review the DocumentFinalization project
  2. Create and register the event receiver
  3. Open and Save the file in SharePoint
  4. Mark the document as finalized

Estimated time to complete this lab: 45 minutes.

Starting Materials

This Hands-On Lab includes the following starting materials.

  • Visual Studio solutions. The lab provides the following Visual Studio solutions that you can use as starting point for the exercises Lab instructions will reference the Training Kit location after installation as %Office2010DeveloperTrainingKitPath%.
    • %Office2010DeveloperTrainingKitPath%\Labs\OpenXML\Source\[language]\Starter\DocumentFinalization.sln: Use the Open XML SDK to update the finalization state of a document when its list property of Published State is set to Published.
    Note:
    Inside the lab’s Source folder, you will find a Solution folder containing an end solution with the completed lab exercise.