<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Brian Jones &amp; Zeyad Rajabi: Office Solutions</title><subtitle type="html">I'm Brian Jones, a program manager in Office. I've been working on the XML functionality and file formats in Office, as well as other technologies folks use for extending Office in various ways. In this blog, I'll focus on the types of Business Applications people are building that leverages Office functionality. </subtitle><id>http://blogs.msdn.com/brian_jones/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/brian_jones/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2009-08-03T09:05:00Z</updated><entry><title>Announcing the Release of the December 2009 CTP for the Open XML SDK</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/12/14/announcing-the-release-of-the-december-2009-ctp-for-the-open-xml-sdk.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/12/14/announcing-the-release-of-the-december-2009-ctp-for-the-open-xml-sdk.aspx</id><published>2009-12-14T23:09:00Z</published><updated>2009-12-14T23:09:00Z</updated><content type="html">&lt;P&gt;I'm really happy to announce the &lt;A href="http://go.microsoft.com/fwlink/?LinkId=127912" mce_href="http://go.microsoft.com/fwlink/?LinkId=127912"&gt;4&lt;SUP&gt;th&lt;/SUP&gt; CTP for the Open XML SDK 2.0 for Microsoft Office&lt;/A&gt;! There were four major improvements we made to the SDK: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Full support for the Office 2010 Open XML formats &lt;/LI&gt;
&lt;LI&gt;Office 2010 schema and semantic level validation &lt;/LI&gt;
&lt;LI&gt;General improvements based on a recent Open XML SDK usability study &lt;/LI&gt;
&lt;LI&gt;Open XML SDK tools improvement &lt;/LI&gt;&lt;/OL&gt;
&lt;H2&gt;Full Support for the Office 2010 Open XML Formats &lt;/H2&gt;
&lt;P&gt;With the latest CTP you are able to create, edit, and consume Office generated Open XML formats for either Office 2007 or Office 2010. Looking back at the original Open XML SDK architecture diagram I showed you when we first &lt;A href="http://blogs.msdn.com/brian_jones/archive/2008/10/06/open-xml-format-sdk-2-0.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/10/06/open-xml-format-sdk-2-0.aspx"&gt;announced the Open XML SDK&lt;/A&gt;, we have extended the base level layer to include Office 2010 support: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image.png" mce_href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_thumb.png" width=616 height=171 mce_src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;What does that mean? Well, let me show you some examples. &lt;/P&gt;
&lt;P&gt;The Open XML Packaging API component allows you to add/remove parts within an Open XML package. This component functions by providing you strongly typed classes for every part within a package. In Office 2010 we've added new parts to the package in order to support some of our new features. With this CTP you are able to deal with these new parts with classes. For example, Word 2010 added a new part called &lt;A href="http://msdn.microsoft.com/en-us/library/dd908153.aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd908153.aspx"&gt;stylesWithEffects&lt;/A&gt;. This part is used to help round trip styles that are based on &lt;A href="http://blogs.msdn.com/microsoft_office_word/archive/2009/07/14/introducing-word-2010.aspx" mce_href="http://blogs.msdn.com/microsoft_office_word/archive/2009/07/14/introducing-word-2010.aspx"&gt;Word's new text effects feature&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_3.png" mce_href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_3.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_thumb_3.png" width=478 height=282 mce_src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Open XML Low Level DOM component allows you to create, edit, or consume xml contained in parts contained within an Open XML package. Like the packaging API component, this component functions by providing you with strongly typed classes for every element supported within the xml. For example, imagine we have the following text in a Word document, which uses the new text effects feature glow: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_4.png" mce_href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_4.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_thumb_4.png" width=399 height=107 mce_src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_thumb_4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This text is represented in xml and the Open XML SDK as the following: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse" border=0 width=882&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 310px"&gt;
&lt;COL style="WIDTH: 328px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR style="BACKGROUND: #4f81bd"&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; BORDER-LEFT: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;XML&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid; BORDER-RIGHT: #4f81bd 1pt solid" width=492&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Open XML SDK Code&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; BORDER-LEFT: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP-STYLE: none"&gt;
&lt;P&gt;&amp;nbsp;&lt;A href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/clip_image001.png" mce_href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/clip_image001.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=clip_image001 border=0 alt=clip_image001 src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/clip_image001_thumb.png" width=361 height=361 mce_src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/clip_image001_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP-STYLE: none; BORDER-RIGHT: #4f81bd 1pt solid" width=492&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; W14 = DocumentFormat.OpenXml.Office2010.Word; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;... &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Run&lt;/SPAN&gt; run2 = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Run&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;RunProperties&lt;/SPAN&gt; runProperties1 = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;RunProperties&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;W14.&lt;SPAN style="COLOR: #2b91af"&gt;Glow&lt;/SPAN&gt; glow1 = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; W14.&lt;SPAN style="COLOR: #2b91af"&gt;Glow&lt;/SPAN&gt;() { GlowRadius = 228600L }; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;W14.&lt;SPAN style="COLOR: #2b91af"&gt;SchemeColor&lt;/SPAN&gt; schemeColor1 = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; W14.&lt;SPAN style="COLOR: #2b91af"&gt;SchemeColor&lt;/SPAN&gt;() &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;{ Val = W14.&lt;SPAN style="COLOR: #2b91af"&gt;SchemeColorValues&lt;/SPAN&gt;.ExtraSchemeColor5 }; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;W14.&lt;SPAN style="COLOR: #2b91af"&gt;Alpha&lt;/SPAN&gt; alpha1 = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; W14.&lt;SPAN style="COLOR: #2b91af"&gt;Alpha&lt;/SPAN&gt;() { Val = 60000 }; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;W14.&lt;SPAN style="COLOR: #2b91af"&gt;SaturationModulation&lt;/SPAN&gt; saturationModulation1 = &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; W14.&lt;SPAN style="COLOR: #2b91af"&gt;SaturationModulation&lt;/SPAN&gt;() { Val = 175000 }; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;schemeColor1.Append(alpha1); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;schemeColor1.Append(saturationModulation1); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;glow1.Append(schemeColor1); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;runProperties1.Append(glow1); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Text&lt;/SPAN&gt; text2 = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Text&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;text2.Text = &lt;SPAN style="COLOR: #a31515"&gt;"text effects"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;... &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;As you can see from the code snippet above, leveraging the Office 2010 Open XML functionality of the SDK is as simple as including the appropriate set of namespace references. &lt;/P&gt;
&lt;H2&gt;Office 2010 Schema and Semantic Level Validation &lt;/H2&gt;
&lt;P&gt;In a previous post I talked about &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/09/24/finding-open-xml-errors-with-open-xml-sdk-validation.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/09/24/finding-open-xml-errors-with-open-xml-sdk-validation.aspx"&gt;how to find Open XML errors with the Open XML SDK validation functionality&lt;/A&gt;. In that post, I talked about finding both schema and semantic (constraints defined in the prose of the documentation that are not represented in schema markup) validation errors. With the latest SDK CTP you are now able to differentiate between errors specific to Office 2007 or Office 2010. The code to validate a file is pretty much the same as the code I showed in the previous post mentioned. The major difference is that we moved the validation functionality to be under its own namespace reference: "&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; DocumentFormat.OpenXml.Validation&lt;/SPAN&gt;". We moved this functionality to its own namespace to improve discoverability of the feature. The &lt;SPAN style="FONT-FAMILY: courier new; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;OpenXmlValidator&lt;/SPAN&gt; class now takes in an enumeration called &lt;SPAN style="FONT-FAMILY: courier new; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;FileFormatVersions&lt;/SPAN&gt; that allows you to specify either Office 2007 or 2010: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_5.png" mce_href="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_5.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_thumb_5.png" width=566 height=110 mce_src="http://zeyadrajabi.members.winisp.net/AnnouncingtheReleaseoftheDecember2009CTP_D6BC/image_thumb_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The validation functionality also has the ability to automatically deal with extensibility markup, like alternate content blocks, as defined by the Open XML standard. &lt;/P&gt;
&lt;H2&gt;General Open XML SDK Improvements &lt;/H2&gt;
&lt;P&gt;We recently conducted a usability study for the Open XML SDK where we asked participants to complete a set of tasks. Based on the results of the study we found that users had issues around the complexity of the Open XML SDK Open methods. In the August 2009 CTP of the SDK, each of the classes &lt;SPAN style="FONT-FAMILY: courier new; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;WordprocessingDocument&lt;/SPAN&gt;, &lt;SPAN style="FONT-FAMILY: courier new; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;SpreadsheetDocument&lt;/SPAN&gt; and &lt;SPAN style="FONT-FAMILY: courier new; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;PresentationDocument&lt;/SPAN&gt; had nine overloaded Open methods. For example, let's look at the &lt;SPAN style="FONT-FAMILY: courier new; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;WordprocessingDocument&lt;/SPAN&gt; class as an example: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Package&lt;/SPAN&gt; package); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Package&lt;/SPAN&gt; package, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; autoSave); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; stream, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; path, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Package&lt;/SPAN&gt; package, &lt;SPAN style="COLOR: #2b91af"&gt;MCMode&lt;/SPAN&gt; mode, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; processMCInWholePackage); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; stream, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; autoSave); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; path, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; autoSave); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; stream, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable, &lt;SPAN style="COLOR: #2b91af"&gt;MCMode&lt;/SPAN&gt; mode, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; processMCInWholePackage); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; path, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable, &lt;SPAN style="COLOR: #2b91af"&gt;MCMode&lt;/SPAN&gt; mode, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; processMCInWholePackage); &lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Now with the latest CTP, the number of overloaded methods for Open has been reduced to six methods: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Package&lt;/SPAN&gt; package); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Package&lt;/SPAN&gt; package, &lt;SPAN style="COLOR: #2b91af"&gt;OpenSettings&lt;/SPAN&gt; openSettings); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; stream, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; path, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: #2b91af"&gt;Stream&lt;/SPAN&gt; stream, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable, &lt;SPAN style="COLOR: #2b91af"&gt;OpenSettings&lt;/SPAN&gt; openSettings); &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-FAMILY: courier new; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt; Open(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; path, &lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; isEditable, &lt;SPAN style="COLOR: #2b91af"&gt;OpenSettings&lt;/SPAN&gt; openSettings);&lt;/SPAN&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Advanced open settings are now part of a new class called &lt;SPAN style="FONT-FAMILY: courier new; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;OpenSettings&lt;/SPAN&gt;. This class allows you to pre-process documents according to markup compatibility, auto save files, or caps the open method to deal with a specific number of characters within a part. Hopefully this change will make it easier to deal with the Open method. &lt;/P&gt;
&lt;H2&gt;Open XML SDK Tool Improvements &lt;/H2&gt;
&lt;P&gt;The last major improvement I want to call out is around the free Open XML SDK tool that comes with the SDK. In the August 2009 CTP, the Open XML SDK shipped with three separate tools: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Document Reflector &lt;/LI&gt;
&lt;LI&gt;Open XML Class Explorer &lt;/LI&gt;
&lt;LI&gt;Open XML Diff &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Based on feedback we have separated the download of the tools from the SDK dll. In other words, the &lt;A href="http://go.microsoft.com/fwlink/?LinkId=127912" mce_href="http://go.microsoft.com/fwlink/?LinkId=127912"&gt;Open XML SDK download page&lt;/A&gt; now has two download links: one for the SDK dll and one for a new consolidated Open XML SDK tool. As of the December 2009 CTP, the Open XML SDK tools are consolidated into one tool. In addition we've added some new functionality to the SDK. Here is a video that shows you an overview of the new tool: &lt;/P&gt;
&lt;P&gt;
&lt;OBJECT width=425 height=344&gt;&lt;PARAM NAME="movie" VALUE="http://www.youtube.com/v/KSSMLR19JWA&amp;amp;hl=en&amp;amp;fs=1"&gt;&lt;PARAM NAME="allowFullScreen" VALUE="true"&gt;&lt;PARAM NAME="allowscriptaccess" VALUE="always"&gt;
&lt;embed src="http://www.youtube.com/v/KSSMLR19JWA&amp;amp;hl=en&amp;amp;fs=1" mce_src="http://www.youtube.com/v/KSSMLR19JWA&amp;amp;hl=en&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/OBJECT&gt;&lt;/P&gt;
&lt;P&gt;The new tool adds the following functionality: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Documentation for Office 2010 Open XML formats &lt;/LI&gt;
&lt;LI&gt;Validation functionality. This feature allows you to validate Open XML files according to Office 2007 or Office 2010 &lt;/LI&gt;
&lt;LI&gt;New reflection feature that combines reflection with the Open XML Diff feature. This new feature allows you to automatically generate SDK code that transforms one document into another document &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Let us know what you think of the new tool. I think of the new tool as the Open XML version of Macro Recording. &lt;/P&gt;
&lt;H2&gt;More Feedback Always Welcome &lt;/H2&gt;
&lt;P&gt;Please continue to send us your feedback, either on this blog or at our &lt;A href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=589" mce_href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=589"&gt;Microsoft Connect site for the Open XML SDK&lt;/A&gt;. We look forward to hearing from you. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9936805" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /><category term="Office 2010" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx" /></entry><entry><title>Extending the Reach of Excel Services with the Open XML SDK</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/12/03/extending-the-reach-of-excel-services-with-the-open-xml-sdk.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/12/03/extending-the-reach-of-excel-services-with-the-open-xml-sdk.aspx</id><published>2009-12-03T21:08:00Z</published><updated>2009-12-03T21:08:00Z</updated><content type="html">&lt;p&gt;&lt;em&gt;Note: Updated post to point to a YouTube video that is shorter than 10 minutes&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;In Brian's last blog he talked about &lt;a href="http://blogs.msdn.com/brian_jones/archive/2009/11/03/open-xml-and-office-services.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/11/03/open-xml-and-office-services.aspx"&gt;Open XML and Office Services&lt;/a&gt; as a one-two punch to complete many types of solutions. I am going to start writing some posts that showcase these two technologies working together. Excel is a great tool for connecting to multiple types of data sources, like databases or XML files. Unfortunately, Excel has no concept of connecting to other types of Office documents, like Word files. This fact is important because information workers are pumping out more and more Office documents that contain lots of relevant business data. These documents are becoming just as important as data contained within databases. In today's post, I am going to show you how to extend the reach of &lt;a href="http://blogs.msdn.com/excel/archive/2009/10/21/more-updates-from-spc.aspx" mce_href="http://blogs.msdn.com/excel/archive/2009/10/21/more-updates-from-spc.aspx"&gt;Excel Services&lt;/a&gt; and hosted charts to gather data from within a library of Word documents. &lt;/p&gt;  &lt;p&gt;If you want to jump straight into the code, feel free to download this solution &lt;a href="http://zeyadrajabi.members.winisp.net/sourcecode/ExcelServices.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/ExcelServices.zip"&gt;here&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/_oyF9-TRcAs&amp;amp;hl=en&amp;amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/_oyF9-TRcAs&amp;amp;hl=en&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;h2&gt;Scenario &lt;/h2&gt;  &lt;p&gt;As a Program Manager (PM) in Office, one of our tasks is to write specifications for features that we are designing for the product. These specifications exist in different stages depending on how far along we are in the design. For example, a stage 0 specification is essentially just a placeholder document with no content. A stage 5 specification is a document that contains the full design for a feature and is ready to be coded by developers. Along the way we inevitably run into open issues that must be addressed before the feature can be coded properly. In order to help us track open issues within a document we included a custom style called &amp;quot;Issue&amp;quot; as part of our specification template. This style applies a yellowish background color to a paragraph so that the paragraph easily sticks out. Here is a screenshot of what this style looks like: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image.png" mce_href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb.png" width="626" height="348" mce_src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb.png" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Whenever a PM encounters an open issue he/she applies this custom style to the content within the specification. Wouldn't it be great if you can generate a dynamic chart that shows the number of open issues for every PM per given specification stage? This chart would represent the relative health of a particular specification library. &lt;/p&gt;  &lt;h2&gt;Solution &lt;/h2&gt;  &lt;p&gt;The scenario I listed above talks about interrogating a repository of Word documents and counting the number of open issues within each of the documents. In order to accomplish this scenario we will need to take the following actions: &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create a template Excel spreadsheet that represents the look and feel of the chart we want to display &lt;/li&gt;    &lt;li&gt;Add an Excel Services web part to a SharePoint site that displays a chart hosted in our template Excel spreadsheet &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;For every Word document in a SharePoint library find the following information: &lt;/div&gt;      &lt;ol&gt;       &lt;li&gt;Program Manager name assigned to the specification &lt;/li&gt;        &lt;li&gt;Specification stage &lt;/li&gt;        &lt;li&gt;The number of open issues within the specification &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;When all the data has been gathered, inject the data into the appropriate location in the template Excel spreadsheet &lt;/li&gt;    &lt;li&gt;     &lt;div&gt;Create a web part button that allows users to refresh the chart (the refresh button will perform steps 3 and 4) &lt;/div&gt;      &lt;ol&gt;       &lt;li&gt;I am going to skip on showing this part since the link to my solution includes source code that shows you how to do this task &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;h2&gt;The Template &lt;/h2&gt;  &lt;p&gt;For the sake of this post and the scenario described above I have created the following template Excel spreadsheet: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_3.png" mce_href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_3.png" width="642" height="528" mce_src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_3.png" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This spreadsheet contains only one sheet with a blank chart. The chart will display the number of open issues across all the program managers listed within a SharePoint library broken down by the specification status. The chart is given a specific name so that we can reference it within our Excel Services web part. Add this template document to a SharePoint library. &lt;/p&gt;  &lt;h2&gt;Creating an Excel Services Web Part in SharePoint &lt;/h2&gt;  &lt;p&gt;&lt;em&gt;Note: I am going to show you how to create a web part within SharePoint 2010, but you should be able to do the same thing within SharePoint 2007 (since Excel Services is not new to 2010). &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;On a SharePoint site where you are an admin, click on the menu command with your name and select Personalize this Page option: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_4.png" mce_href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_4.png" width="652" height="420" mce_src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_4.png" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At this point you have the ability to change the look of the page. Click on the Add a Web Part link: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_5.png" mce_href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_5.png" width="660" height="566" mce_src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_5.png" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the Categories section select Office Client Applications. In the Web Parts section select Excel Web Access: &lt;/p&gt;  &lt;p&gt;&lt;a href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_6.png" mce_href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_6.png" width="672" height="430" mce_src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_6.png" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now we need to link our Excel Services web part to our template Excel spreadsheet. Click the link to open the tool pane, which allows you to reference the correct Excel spreadsheet. In the Excel Services web part properties pane add the following information: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Name of the referenced workbook &lt;/li&gt;    &lt;li&gt;Name of the chart to be added in the Named Item field &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_7.png" mce_href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_7.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_7.png" width="680" height="492" mce_src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_7.png" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;At this point we have an Excel Services web part that shows the chart in our Excel spreadsheet template. &lt;/p&gt;  &lt;h2&gt;Gathering Data from a Library of Word Documents &lt;/h2&gt;  &lt;p&gt;The first step in this task is to iterate through all the Word documents in a given specification library. Here is a code snippet to accomplish this task: &lt;/p&gt;  &lt;div&gt;   &lt;table style="border-collapse: collapse; background: #dbe5f1" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 539px" /&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;       &lt;tr&gt;         &lt;td style="border-bottom: black 0.5pt solid; border-left: black 0.5pt solid; padding-bottom: 1px; padding-left: 7px; padding-right: 7px; border-top: black 0.5pt solid; border-right: black 0.5pt solid; padding-top: 1px" valign="middle"&gt;           &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;SPWeb&lt;/span&gt; myWebSite = &lt;span style="color: #2b91af"&gt;SPContext&lt;/span&gt;.Current.Web; &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&amp;#160;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;SPDocumentLibrary&lt;/span&gt; specLibrary = myWebSite &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;.Lists[&lt;span style="color: #a31515"&gt;&amp;quot;Sample Spec Library&amp;quot;&lt;/span&gt;] &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SPDocumentLibrary&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&amp;#160;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Read all Word documents in the library&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;SPListItem&lt;/span&gt; item &lt;span style="color: blue"&gt;in&lt;/span&gt; specLibrary.Items) &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;byte&lt;/span&gt;[] byteArray = item.File.OpenBinary(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt; mem = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt;()) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;mem.Write(byteArray, &lt;span style="color: brown"&gt;0&lt;/span&gt;, (&lt;span style="color: blue"&gt;int&lt;/span&gt;)byteArray.Length); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Read the Word document into the Open XML SDK&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;WordprocessingDocument&lt;/span&gt; myDoc = &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;WordprocessingDocument&lt;/span&gt;.Open(mem, &lt;span style="color: blue"&gt;true&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Do something&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;}&lt;/span&gt;&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt;  &lt;p&gt;Now that we have access to the Word documents we need to count the number of paragraphs that have the style &amp;quot;Issue&amp;quot; applied. I have already written a post on how to accomplish this task. Check out &lt;a href="http://blogs.msdn.com/brian_jones/archive/2009/05/05/retrieving-word-content-based-on-styles.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/05/05/retrieving-word-content-based-on-styles.aspx"&gt;retrieving Word content based on styles&lt;/a&gt;. I am going to reuse the same methods I talked about in that previous post for this scenario. I will reuse the method called &lt;span style="font-family: consolas; font-size: 10pt"&gt;GetParagraphListByStyle&lt;/span&gt;, which returns a list of paragraphs given a main document part and a specific style name. &lt;/p&gt;  &lt;p&gt;Gathering the PM associated with the specification and the spec status is a matter of retrieving content within a specific content control. In my solution I am going to store the PM name, the number of open issues in the specification and the status of the specification within a hash table. Here is the code snippet I used to store the information: &lt;/p&gt;  &lt;div&gt;   &lt;table style="border-collapse: collapse; background: #dbe5f1" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 557px" /&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;       &lt;tr&gt;         &lt;td style="border-bottom: black 0.5pt solid; border-left: black 0.5pt solid; padding-bottom: 1px; padding-left: 7px; padding-right: 7px; border-top: black 0.5pt solid; border-right: black 0.5pt solid; padding-top: 1px" valign="middle"&gt;           &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;Hashtable&lt;/span&gt; specTable = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;Hashtable&lt;/span&gt;(); &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&amp;#160;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Read all Word documents in the library&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;foreach&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;SPListItem&lt;/span&gt; item &lt;span style="color: blue"&gt;in&lt;/span&gt; specLibrary.Items) &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; pmName = &lt;span style="color: #a31515"&gt;&amp;quot;&amp;quot;&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt; numOpenIssues = &lt;span style="color: brown"&gt;0&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt; status = &lt;span style="color: brown"&gt;0&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;... &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Read the Word document into the Open XML SDK&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;WordprocessingDocument&lt;/span&gt; myDoc = &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;WordprocessingDocument&lt;/span&gt;.Open(mem, &lt;span style="color: blue"&gt;true&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;MainDocumentPart&lt;/span&gt; mainPart = myDoc.MainDocumentPart; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Find out the program manager name associated with the spec&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;Word.&lt;span style="color: #2b91af"&gt;DataBinding&lt;/span&gt; binding = mainPart.Document &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;.Descendants&amp;lt;Word.&lt;span style="color: #2b91af"&gt;DataBinding&lt;/span&gt;&amp;gt;() &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;.Where(d =&amp;gt; d.XPath.Value.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;PM2&amp;quot;&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;.First(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;pmName = binding.Ancestors&amp;lt;Word.&lt;span style="color: #2b91af"&gt;SdtCell&lt;/span&gt;&amp;gt;().First().InnerText; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Get all paragraphs in the spec that have a style &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//applied on the paragraphs called &amp;quot;Issue&amp;quot;&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;Word.&lt;span style="color: #2b91af"&gt;Paragraph&lt;/span&gt;&amp;gt; paraIssueList = &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;GetParagraphListByStyle(mainPart, &lt;span style="color: #a31515"&gt;&amp;quot;Issue&amp;quot;&lt;/span&gt;); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;numOpenIssues = paraIssueList.Count(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Find out the spec status (either 0, 1, 2, 3, 4, or 5)&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;IEnumerable&lt;/span&gt;&amp;lt;Word.&lt;span style="color: #2b91af"&gt;Paragraph&lt;/span&gt;&amp;gt; paraSpecStatusList = &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;GetParagraphListByStyle(mainPart, &lt;span style="color: #a31515"&gt;&amp;quot;SpecStatus&amp;quot;&lt;/span&gt;); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;foreach&lt;/span&gt; (Word.&lt;span style="color: #2b91af"&gt;Paragraph&lt;/span&gt; p &lt;span style="color: blue"&gt;in&lt;/span&gt; paraSpecStatusList) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; specStatus = p.InnerText; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (specStatus.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;status = &lt;span style="color: brown"&gt;0&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;span style="color: blue"&gt;if&lt;/span&gt; (specStatus.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;status = &lt;span style="color: brown"&gt;1&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;span style="color: blue"&gt;if&lt;/span&gt; (specStatus.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;2&amp;quot;&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;status = &lt;span style="color: brown"&gt;2&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;span style="color: blue"&gt;if&lt;/span&gt; (specStatus.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;3&amp;quot;&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;status = &lt;span style="color: brown"&gt;3&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;span style="color: blue"&gt;if&lt;/span&gt; (specStatus.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;4&amp;quot;&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;status = &lt;span style="color: brown"&gt;4&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;span style="color: blue"&gt;if&lt;/span&gt; (specStatus.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;5&amp;quot;&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;status = &lt;span style="color: brown"&gt;5&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Once we find all the data lets add it to a hashtable&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//We will use this data to build up our chart&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (specTable.Contains(pmName)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt;[] specStatusValues = (&lt;span style="color: blue"&gt;int&lt;/span&gt;[])specTable[pmName]; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;specStatusValues[status] += numOpenIssues; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;else&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt;[] specStatusValues = { &lt;span style="color: brown"&gt;0&lt;/span&gt;, &lt;span style="color: brown"&gt;0&lt;/span&gt;, &lt;span style="color: brown"&gt;0&lt;/span&gt;, &lt;span style="color: brown"&gt;0&lt;/span&gt;, &lt;span style="color: brown"&gt;0&lt;/span&gt;, &lt;span style="color: brown"&gt;0&lt;/span&gt; }; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;specStatusValues[status] += numOpenIssues; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;specTable.Add(pmName, specStatusValues); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;}&lt;/span&gt;&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt;  &lt;p&gt;Notice that the specification status can be one of six values, from Stage 0 to Stage 5. &lt;/p&gt;  &lt;h2&gt;Adding Data to my Spreadsheet &lt;/h2&gt;  &lt;p&gt;At this point we have all the data from our document library. All that is left is to insert this data into our Excel spreadsheet. This part of the solution is analogous to my previous post on &lt;a href="http://blogs.msdn.com/brian_jones/archive/2008/11/04/document-assembly-solution-for-spreadsheetml.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/11/04/document-assembly-solution-for-spreadsheetml.aspx"&gt;document assembly for SpreadsheetML&lt;/a&gt;. We are simply going to create new rows and cells in our spreadsheet for every piece of data within our hash table. Notice that we are adding two types of cells: value based cells and text based cells. These two types of cells are stored differently in Excel. Here is the code snippet used to accomplish this task: &lt;/p&gt;  &lt;div&gt;   &lt;table style="border-collapse: collapse; background: #dbe5f1" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 696px" /&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;       &lt;tr&gt;         &lt;td style="border-bottom: black 0.5pt solid; border-left: black 0.5pt solid; padding-bottom: 1px; padding-left: 7px; padding-right: 7px; border-top: black 0.5pt solid; border-right: black 0.5pt solid; padding-top: 1px" valign="middle"&gt;           &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;void&lt;/span&gt; AddDataToExcel(&lt;span style="color: #2b91af"&gt;Hashtable&lt;/span&gt; specTable) &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;SPWeb&lt;/span&gt; myWebsite = &lt;span style="color: #2b91af"&gt;SPContext&lt;/span&gt;.Current.Web; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;SPDocumentLibrary&lt;/span&gt; templateLibrary = myWebsite &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;.Lists[&lt;span style="color: #a31515"&gt;&amp;quot;Excel Template&amp;quot;&lt;/span&gt;] &lt;span style="color: blue"&gt;as&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SPDocumentLibrary&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;SPFile&lt;/span&gt; template = myWebsite &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;.GetFile(&lt;span style="color: #a31515"&gt;@&amp;quot;http://wordteamserver/excelservices/Excel%20Template/template.xlsx&amp;quot;&lt;/span&gt;); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;template.CopyTo(outputFileName, &lt;span style="color: blue"&gt;true&lt;/span&gt;); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;SPFile&lt;/span&gt; output = myWebsite.GetFile(template); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;byte&lt;/span&gt;[] byteArray = output.OpenBinary(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Open the output workbook so we can add data to it&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt; mem = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;MemoryStream&lt;/span&gt;()) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;mem.Write(byteArray, &lt;span style="color: brown"&gt;0&lt;/span&gt;, (&lt;span style="color: blue"&gt;int&lt;/span&gt;)byteArray.Length); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;SpreadsheetDocument&lt;/span&gt; myWorkbook = &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;SpreadsheetDocument&lt;/span&gt;.Open(mem, &lt;span style="color: blue"&gt;true&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Get the first sheet in the workbook&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;WorkbookPart&lt;/span&gt; workbookPart = myWorkbook.WorkbookPart; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;WorksheetPart&lt;/span&gt; worksheetPart = &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;GetWorkSheetPart(workbookPart, &lt;span style="color: #a31515"&gt;&amp;quot;Sheet1&amp;quot;&lt;/span&gt;); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Sheet data contains all the data in the rows/cells&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;SpreadSheet.&lt;span style="color: #2b91af"&gt;SheetData&lt;/span&gt; sheetData = &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;worksheetPart.Worksheet.GetFirstChild&amp;lt;SpreadSheet.&lt;span style="color: #2b91af"&gt;SheetData&lt;/span&gt;&amp;gt;(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Go through our spec hashtable so we can add the data to workbook&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;IDictionaryEnumerator&lt;/span&gt; enumerator = specTable.GetEnumerator(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;while&lt;/span&gt; (enumerator.MoveNext()) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; pmName = (&lt;span style="color: blue"&gt;string&lt;/span&gt;)enumerator.Key; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt;[] specStatusValues = (&lt;span style="color: blue"&gt;int&lt;/span&gt;[])enumerator.Value; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//create a new row for each program manager&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;SpreadSheet.&lt;span style="color: #2b91af"&gt;Row&lt;/span&gt; r = &lt;span style="color: blue"&gt;new&lt;/span&gt; SpreadSheet.&lt;span style="color: #2b91af"&gt;Row&lt;/span&gt;(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Add a cell to the row with the program manager name&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//note that the name is a string&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;SpreadSheet.&lt;span style="color: #2b91af"&gt;Cell&lt;/span&gt; firstCell = &lt;span style="color: blue"&gt;new&lt;/span&gt; SpreadSheet.&lt;span style="color: #2b91af"&gt;Cell&lt;/span&gt;(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;firstCell.DataType = SpreadSheet.&lt;span style="color: #2b91af"&gt;CellValues&lt;/span&gt;.InlineString; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;SpreadSheet.&lt;span style="color: #2b91af"&gt;InlineString&lt;/span&gt; inlineString = &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 180pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt; SpreadSheet.&lt;span style="color: #2b91af"&gt;InlineString&lt;/span&gt;(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;SpreadSheet.&lt;span style="color: #2b91af"&gt;Text&lt;/span&gt; t = &lt;span style="color: blue"&gt;new&lt;/span&gt; SpreadSheet.&lt;span style="color: #2b91af"&gt;Text&lt;/span&gt;(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;t.Text = pmName; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;inlineString.Append(t); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;firstCell.Append(inlineString); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;r.Append(firstCell); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Let's add values to the other cells&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//specifically we will add the number of open issues&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//across the different spec status values&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt; (&lt;span style="color: blue"&gt;int&lt;/span&gt; i = &lt;span style="color: brown"&gt;0&lt;/span&gt;; i &amp;lt; &lt;span style="color: brown"&gt;6&lt;/span&gt;; i++) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 180pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;SpreadSheet.&lt;span style="color: #2b91af"&gt;Cell&lt;/span&gt; sheetCell = &lt;span style="color: blue"&gt;new&lt;/span&gt; SpreadSheet.&lt;span style="color: #2b91af"&gt;Cell&lt;/span&gt;(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 180pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;SpreadSheet.&lt;span style="color: #2b91af"&gt;CellValue&lt;/span&gt; v = &lt;span style="color: blue"&gt;new&lt;/span&gt; SpreadSheet.&lt;span style="color: #2b91af"&gt;CellValue&lt;/span&gt;(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 180pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; textValue = specStatusValues[i].ToString(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 180pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;v.Text = textValue; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 180pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;sheetCell.Append(v); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 180pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;r.Append(sheetCell); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 144pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;sheetData.Append(r); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;worksheetPart.Worksheet.Save(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Once we have added all the values we need to update the &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//chart ranges&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;FixChartData(worksheetPart, specTable); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Add output file to library&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;SPFolder&lt;/span&gt; fldr = myWebsite.Folders[&lt;span style="color: #a31515"&gt;&amp;quot;Excel Template&amp;quot;&lt;/span&gt;]; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;fldr.Files.Add(outputFileName, mem, &lt;span style="color: blue"&gt;true&lt;/span&gt;); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;}&lt;/span&gt;&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt;  &lt;p&gt;The GetWorkSheetPart method is the same method I wrote about in my previous post on &lt;a href="http://blogs.msdn.com/brian_jones/archive/2009/02/19/how-to-copy-a-worksheet-within-a-workbook.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/02/19/how-to-copy-a-worksheet-within-a-workbook.aspx"&gt;how to copy a worksheet within a workbook&lt;/a&gt;. &lt;/p&gt;  &lt;h2&gt;Fix Chart Data &lt;/h2&gt;  &lt;p&gt;The last step in the solution is to fix the chart data. Again this code snippet is taken directly from my previous post on &lt;a href="http://blogs.msdn.com/brian_jones/archive/2008/11/04/document-assembly-solution-for-spreadsheetml.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/11/04/document-assembly-solution-for-spreadsheetml.aspx"&gt;document assembly for SpreadsheetML&lt;/a&gt;. In any case, here is the code snippet used to accomplish this task: &lt;/p&gt;  &lt;div&gt;   &lt;table style="border-collapse: collapse; background: #dbe5f1" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 616px" /&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;       &lt;tr&gt;         &lt;td style="border-bottom: black 0.5pt solid; border-left: black 0.5pt solid; padding-bottom: 1px; padding-left: 7px; padding-right: 7px; border-top: black 0.5pt solid; border-right: black 0.5pt solid; padding-top: 1px" valign="middle"&gt;           &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Fix the range of the chart data&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;void&lt;/span&gt; FixChartData(&lt;span style="color: #2b91af"&gt;WorksheetPart&lt;/span&gt; worksheetPart, &lt;span style="color: #2b91af"&gt;Hashtable&lt;/span&gt; specTable) &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;int&lt;/span&gt; totalCount = specTable.Count + &lt;span style="color: brown"&gt;1&lt;/span&gt;; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: #2b91af"&gt;ChartPart&lt;/span&gt; chartPart = worksheetPart.GetPartsOfType&amp;lt;&lt;span style="color: #2b91af"&gt;DrawingsPart&lt;/span&gt;&amp;gt;() &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;.First().ChartParts.First(); &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;foreach&lt;/span&gt; (Charts.&lt;span style="color: #2b91af"&gt;Formula&lt;/span&gt; formula &lt;span style="color: blue"&gt;in&lt;/span&gt; chartPart.ChartSpace &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;.Descendants&amp;lt;Charts.&lt;span style="color: #2b91af"&gt;Formula&lt;/span&gt;&amp;gt;()) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: green"&gt;//Range needs to be updated such that we reference the number of rows&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt; (formula.Text.Contains(&lt;span style="color: #a31515"&gt;&amp;quot;$2&amp;quot;&lt;/span&gt;)) &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;{ &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;&lt;span style="color: blue"&gt;string&lt;/span&gt; s = formula.Text.Split(&lt;span style="color: #a31515"&gt;'$'&lt;/span&gt;)[&lt;span style="color: brown"&gt;1&lt;/span&gt;]; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 108pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;formula.Text += &lt;span style="color: #a31515"&gt;&amp;quot;:$&amp;quot;&lt;/span&gt; + s + &lt;span style="color: #a31515"&gt;&amp;quot;$&amp;quot;&lt;/span&gt; + totalCount; &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 72pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;} &lt;/span&gt;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&amp;#160;&lt;/div&gt;            &lt;div style="margin-left: 36pt"&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;chartPart.ChartSpace.Save(); &lt;/span&gt;&lt;/div&gt;            &lt;div&gt;&lt;span style="font-family: consolas; font-size: 10pt"&gt;}&lt;/span&gt;&lt;/div&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt;  &lt;h2&gt;End Result &lt;/h2&gt;  &lt;p&gt;Running this code I will end up with a chart that represents the number of open issues across a library of Word documents. Clicking Update Chart will ensure the chart reflects the data contained within the library. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_9.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://zeyadrajabi.members.winisp.net/ExtendingtheReachofExcelServiceswiththeO_BDD8/image_thumb_9.png" width="918" height="677" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I am excited about this solution because it shows how you can extend the reach of our services to accomplish other types of solutions. In this case, having Excel reflect data contained within Word documents. &lt;/p&gt;  &lt;p&gt;Zeyad Rajabi&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9932202" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Code Samples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx" /><category term="Zeyad's SDK Examples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /></entry><entry><title>Open XML SDK + Word Automation Services Presentation at PDC</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/11/23/open-xml-sdk-word-automation-services-presentation-at-pdc.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/11/23/open-xml-sdk-word-automation-services-presentation-at-pdc.aspx</id><published>2009-11-23T18:38:00Z</published><updated>2009-11-23T18:38:00Z</updated><content type="html">&lt;P&gt;I just got back from &lt;A href="http://microsoftpdc.com/" mce_href="http://microsoftpdc.com/"&gt;PDC&lt;/A&gt; and am excited to share with you guys the presentation, deck, and code samples I showed at &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/11/10/open-xml-sdk-sessions-at-the-professional-developers-conference-pdc.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/11/10/open-xml-sdk-sessions-at-the-professional-developers-conference-pdc.aspx"&gt;my session&lt;/A&gt;. I also want to thank everyone who attended my session. Here is my recorded session: &lt;/P&gt; &lt;P&gt;   &lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
        width="800" height="450"&gt;         &lt;param name="source" value="http://microsoftpdc.com/Skins/PDC09/Styles/players/VideoPlayer2009_03_27.xap" /&gt;         &lt;param name="initParams" value="m=http://ecn.channel9.msdn.com/o9/pdc09/wmvhigh/PR09.wmv,autostart=false,autohide=true,showembed=true, thumbnail=http://microsoftpdc.com/Skins/PDC09/Styles/images/DefaultPlayerBackground.png, postid=0" /&gt;         &lt;param name="background" value="#00FFFFFF" /&gt;         &lt;param name="enableHtmlAccess" value="true" /&gt;         &lt;a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"&gt;             &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /&gt;         &lt;/a&gt;     &lt;/object&gt;&lt;/P&gt; &lt;P&gt;You can find my session deck here: &lt;A href="http://ecn.channel9.msdn.com/o9/pdc09/ppt/PR09.pptx" mce_href="http://ecn.channel9.msdn.com/o9/pdc09/ppt/PR09.pptx"&gt;http://ecn.channel9.msdn.com/o9/pdc09/ppt/PR09.pptx&lt;/A&gt; &lt;/P&gt; &lt;P&gt;You can find all my code samples for the demos I showed here: &lt;A href="http://zeyadrajabi.members.winisp.net/sourcecode/PDC%20Open%20XML%20demos.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/PDC%20Open%20XML%20demos.zip"&gt;http://zeyadrajabi.members.winisp.net/sourcecode/PDC%20Open%20XML%20demos.zip&lt;/A&gt; &lt;/P&gt; &lt;P&gt;In Brian's last post, he gave a good &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/11/03/open-xml-and-office-services.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/11/03/open-xml-and-office-services.aspx"&gt;overview of using the Open XML SDK and Office Services together&lt;/A&gt;. In the next couple of months I am going to start blogging more about scenarios and solutions that leverage both the SDK and Office Services to create rich Office document solutions. &lt;/P&gt; &lt;P&gt;&lt;EM&gt;Note: I am still waiting for &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/10/09/open-xml-sdk-sessions-at-the-sharepoint-conference-spc.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/10/09/open-xml-sdk-sessions-at-the-sharepoint-conference-spc.aspx"&gt;my two sessions at SPC&lt;/A&gt; to get published. As soon as they do, I will share them out with you guys. &lt;/EM&gt;&lt;/P&gt; &lt;P&gt;Zeyad Rajabi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927445" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Conferences" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Conferences/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Code Samples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx" /><category term="Zeyad's SDK Examples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /><category term="Office 2010" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx" /></entry><entry><title>Open XML SDK Sessions at the Professional Developers Conference (PDC)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/11/10/open-xml-sdk-sessions-at-the-professional-developers-conference-pdc.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/11/10/open-xml-sdk-sessions-at-the-professional-developers-conference-pdc.aspx</id><published>2009-11-10T23:53:00Z</published><updated>2009-11-10T23:53:00Z</updated><content type="html">&lt;P&gt;I'm pretty excited, next week I'll be at &lt;A href="http://microsoftpdc.com/" mce_href="http://microsoftpdc.com/"&gt;PDC&lt;/A&gt; in Los Angeles giving another presentation on the Open XML SDK. I'll be at the conference from Nov 17-19, so if you're at PDC do come by and say hi. Here's the description and time of the session I'll be presenting: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 159px"&gt;
&lt;COL style="WIDTH: 94px"&gt;
&lt;COL style="WIDTH: 61px"&gt;
&lt;COL style="WIDTH: 483px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR style="BACKGROUND: #4f81bd"&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; BORDER-LEFT: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Session Title&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Time &amp;amp; Date&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Session Code&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #4f81bd 1pt solid; BORDER-RIGHT: #4f81bd 1pt solid"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; BORDER-LEFT: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none"&gt;
&lt;P&gt;&lt;A href="http://microsoftpdc.com/Sessions/PR09" mce_href="http://microsoftpdc.com/Sessions/PR09"&gt;&lt;STRONG&gt;Document Assembly and Manipulation on Microsoft SharePoint Server 2010 Using Word Automation Services and Open&amp;nbsp;XML&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none"&gt;
&lt;P&gt;11/19/2009 11:30AM &lt;/P&gt;
&lt;P&gt;@ 408B&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none"&gt;
&lt;P&gt;PR09&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: #4f81bd 1pt solid"&gt;
&lt;P&gt;Come learn about the Open XML SDK, which provides a set of .NET APIs to help developers create and manipulate documents in the Open XML Formats, and the Microsoft Office services available in SharePoint Server 2010. Hear how Word Automation Services and Excel Services can be used to build solutions for server environments without the need of the Office clients. Come and check out all the demos and free source code.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;Let me know if there are specific demos you would like to see. Besides the presentation, you will be able to find me at the Office client booth during the week of PDC and at the "Ask the Experts" event. I'm looking forward to hearing feedback from you guys at the conference. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9920514" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Conferences" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Conferences/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /></entry><entry><title>Open XML and Office Services </title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/11/03/open-xml-and-office-services.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/11/03/open-xml-and-office-services.aspx</id><published>2009-11-03T20:16:00Z</published><updated>2009-11-03T20:16:00Z</updated><content type="html">&lt;P&gt;If you didn't see the news up on the Word team blog announcing Word Automation Services, and you have any interest in server side conversion of .docx files into .pdf or .xps, you should definitely go take a look: &lt;A href="http://blogs.msdn.com/microsoft_office_word/archive/2009/10/26/introducing-word-automation-services.aspx" mce_href="http://blogs.msdn.com/microsoft_office_word/archive/2009/10/26/introducing-word-automation-services.aspx"&gt;http://blogs.msdn.com/microsoft_office_word/archive/2009/10/26/introducing-word-automation-services.aspx&lt;/A&gt; &lt;/P&gt;
&lt;H1&gt;Capturing Business Processes in Office &lt;/H1&gt;
&lt;P&gt;I see a lot of different types of solutions people build to make their workgroups run more accurately and efficiently. Many of the solutions are created in order to codify one or more pieces of a business process, and as you can imagine, Office plays a huge role in these processes. For example, there may be people using Outlook for communication; Excel for analysis; Word for documentation; and just about any process ends in PowerPoint where you present the results of the work. &lt;/P&gt;
&lt;P&gt;As we see the shift from a focus on an individual's productivity to a focus on the entire workgroup's productivity, it also means the way in which people program against our applications changes. This is why you see a lot more SharePoint development in addition to traditional Office development (I briefly &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/06/01/office-2010-and-how-it-can-help-you-build-powerful-solutions.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/06/01/office-2010-and-how-it-can-help-you-build-powerful-solutions.aspx"&gt;mentioned&lt;/A&gt; this over the summer). It's also why the Open XML formats and the Open XML SDK were such important investments for us… they help the Office applications continue to play an important role in these workgroup level scenarios. &lt;/P&gt;
&lt;H1&gt;Printing and Re-Calcing on the Server &lt;/H1&gt;
&lt;P&gt;For example, one request we've heard from folks working with the Open XML formats on the server is that they want access to some core client functionality, like printing/layout in Word, or calculations in Excel. A couple weeks ago at the SharePoint conference we announced the next version of &lt;A href="http://blogs.msdn.com/excel/archive/2009/10/21/more-updates-from-spc.aspx" mce_href="http://blogs.msdn.com/excel/archive/2009/10/21/more-updates-from-spc.aspx"&gt;Excel Services&lt;/A&gt;, as well as a new service called &lt;A href="http://blogs.msdn.com/microsoft_office_word/archive/2009/10/26/introducing-word-automation-services.aspx" mce_href="http://blogs.msdn.com/microsoft_office_word/archive/2009/10/26/introducing-word-automation-services.aspx"&gt;Word Automation Services&lt;/A&gt;. These two services are great resources for people doing server side document assembly/manipulation with Open XML. The Open XML formats are great for consuming or generating content for dynamic document assembly scenarios, but often there is also the need to recalc the model, refresh the charts, or print the document, and you don't want to necessarily call back to the client to do this. &lt;/P&gt;
&lt;H1&gt;Server Side Document Assembly Example &lt;/H1&gt;
&lt;P&gt;A quick example to help explain this is a process I've seen a number of times, where banks were trying to do bulk generation of loan applications (thousands a day). There are end users involved in creating the template for the loan application, as well as building out the financial models for how the terms of the loan are determined, but the generation of the individual applications was a bulk server-side process based an incoming list of applicants. The combination of Open XML and content controls makes it pretty easy to create .docx files on the server, but in this scenario the banks wanted to send out either PDFs or hard copies, which meant you needed to include the Word client in the process (and it was obviously the big bottle neck). &lt;/P&gt;
&lt;P&gt;With the new services announced at the SharePoint conference though, you get the perfect mix of software + services to solve the scenario. The end users can continue to work in the applications they are familiar with (Word &amp;amp; Excel) to build out the template and financial model, and the bulk generation can all happen on the server in an automated process: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.jonesxml.com/images/clientServer.png"&gt;&lt;IMG alt="" src="http://www.jonesxml.com/images/clientServerSmall.png" mce_src="http://www.jonesxml.com/images/clientServerSmall.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Here's a quick step by step explanation of the process: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;EM&gt;Client-side&lt;/EM&gt;: Loan Template author generates the template for the loan application, and uses content controls to specify where the data should go. He saves it up to SharePoint so others can collaborate with him. &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Client-side&lt;/EM&gt;: Folks from the Legal department are able to work with in the document at the same time as the Template author because of the &lt;A href="http://blogs.msdn.com/microsoft_office_word/archive/2009/09/09/co-authoring-in-word-2010.aspx" mce_href="http://blogs.msdn.com/microsoft_office_word/archive/2009/09/09/co-authoring-in-word-2010.aspx"&gt;new co-authoring functionality in Word 2010&lt;/A&gt;. &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Client-side&lt;/EM&gt;: A financial analyst builds up a model for determining whether an applicant should be considered and what the terms of the loan should be. This model is saved up to SharePoint as an .xlsx &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Server-side&lt;/EM&gt;: As new applicants request an application, a server side process takes their data, and uses the Open XML SDK to inject it into xlsx. (&lt;A href="http://blogs.msdn.com/brian_jones/archive/2008/11/04/document-assembly-solution-for-spreadsheetml.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/11/04/document-assembly-solution-for-spreadsheetml.aspx"&gt;Example 1&lt;/A&gt;; &lt;A href="http://blogs.msdn.com/brian_jones/archive/2008/11/10/reading-data-from-spreadsheetml.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/11/10/reading-data-from-spreadsheetml.aspx"&gt;Example 2&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Server&lt;/EM&gt;-side: The financial model (.xlsx) is then sent off to Excel Services to perform calculations and pull out the results &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Server-side&lt;/EM&gt;: The process takes the results of the calculation, and injects them into the Word template, using the content controls to determine what data should go where, producing a .docx file. (&lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/01/05/taking-advantage-of-bound-content-controls.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/01/05/taking-advantage-of-bound-content-controls.aspx"&gt;Example 1&lt;/A&gt;; &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/01/19/pushing-data-from-a-database-into-a-word-document.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/01/19/pushing-data-from-a-database-into-a-word-document.aspx"&gt;Example 2&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Server-side&lt;/EM&gt;: The .docx file is passed off to Word services where a .pdf file is generated, which can either then be sent on to a high volume printer, or e-mailed directly to the applicant. &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Client-side&lt;/EM&gt;: Any of the users can make updates to the documents (assuming this is allowed as part of the workflow), and those changes will automatically make their way into the bulk generation process. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;So, you can see this is a pretty basic but also extremely power scenario, and if you've been reading &lt;A href="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx"&gt;Zeyad's examples&lt;/A&gt; over the past year or so you know how easy this can be with the Open XML SDK. I've been excited about these technologies for a few years now, and it's great that we can finally start talking publicly about them. Zeyad had a couple great demos at the &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/10/21/demos-shown-at-the-sharepoint-conference-spc.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/10/21/demos-shown-at-the-sharepoint-conference-spc.aspx"&gt;SharePoint conference&lt;/A&gt; that really helped show the value of these services in combination with the Open XML formats. We'll post a video of the presentation as soon as it comes available, and will also have separate blog posts that drill into each one over the coming months. &lt;/P&gt;
&lt;P&gt;-Brian&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9916952" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Word" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Word/default.aspx" /><category term="Excel" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Excel/default.aspx" /><category term="PDF" scheme="http://blogs.msdn.com/brian_jones/archive/tags/PDF/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /></entry><entry><title>Migrating your custom solutions to Office 14</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/10/22/migrating-your-custom-solutions-to-office-14.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/10/22/migrating-your-custom-solutions-to-office-14.aspx</id><published>2009-10-23T00:11:54Z</published><updated>2009-10-23T00:11:54Z</updated><content type="html">&lt;p&gt;For those folks who have custom Office solutions within their enterprise, one area that you often need to focus on during the upgrade cycle is testing out those custom solutions to make sure they'll run in the latest version. With Office 14, we're going to provide a great set of tools to make it even easier for folks tasked with deployment. Michael Kiselman provided a great overview today up on Gray Knowlton's blog:  &lt;a href="http://blogs.technet.com/gray_knowlton/archive/2009/10/22/announcing-the-office-2010-application-compatibility-program.aspx"&gt;http://blogs.technet.com/gray_knowlton/archive/2009/10/22/announcing-the-office-2010-application-compatibility-program.aspx&lt;/a&gt;
	&lt;/p&gt;&lt;p&gt;We always focus heavily on testing application compatibility from version to version, and in most cases applications will continue to run just like they did in the older version. From time to time though there are cases where a custom application may need to be updated. The tools Michael describes help with both the discovery and migration processes. 
&lt;/p&gt;&lt;p&gt;-Brian&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9911774" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author></entry><entry><title>Open XML SDK Demos Shown at the SharePoint Conference (SPC)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/10/21/demos-shown-at-the-sharepoint-conference-spc.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/10/21/demos-shown-at-the-sharepoint-conference-spc.aspx</id><published>2009-10-22T04:45:00Z</published><updated>2009-10-22T04:45:00Z</updated><content type="html">&lt;P&gt;First off, I want to thank everyone who attended &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/10/09/open-xml-sdk-sessions-at-the-sharepoint-conference-spc.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/10/09/open-xml-sdk-sessions-at-the-sharepoint-conference-spc.aspx"&gt;my two sessions at SPC&lt;/A&gt; on developing solutions on top of the Open XML SDK. The sessions were recorded, so as soon as they are published to the web I will send you guys some links. In the meantime, I want to share with you guys some really cool demos and source code I presented at the sessions. &lt;/P&gt;
&lt;P&gt;Here is a link to all the demos that I showed, plus a bunch more: &lt;A href="http://zeyadrajabi.members.winisp.net/sourcecode/Open%20XML%20demos.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/Open%20XML%20demos.zip"&gt;http://zeyadrajabi.members.winisp.net/sourcecode/Open XML demos.zip&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;This zip file includes demos I have already blogged about plus a few new solutions around using the Open XML SDK with Office Services. Expect to see future blog posts for the demos that haven't been blogged about yet. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9911107" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Conferences" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Conferences/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Code Samples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx" /><category term="Zeyad's SDK Examples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /></entry><entry><title>Open XML SDK Sessions at the SharePoint Conference (SPC)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/10/09/open-xml-sdk-sessions-at-the-sharepoint-conference-spc.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/10/09/open-xml-sdk-sessions-at-the-sharepoint-conference-spc.aspx</id><published>2009-10-09T23:51:00Z</published><updated>2009-10-09T23:51:00Z</updated><content type="html">&lt;P&gt;We're just a couple of weeks away before the start of the &lt;A href="http://www.mssharepointconference.com/" mce_href="http://www.mssharepointconference.com"&gt;SharePoint Conference&lt;/A&gt; (SPC) being held in Las Vegas. I want to give you guys a heads up that I will be at the conference from Oct 19-22. I'm pretty excited because I will be giving two different presentations on the Open XML SDK at the conference. Here's the description and times of the two sessions I'll be doing: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 162px"&gt;
&lt;COL style="WIDTH: 138px"&gt;
&lt;COL style="WIDTH: 60px"&gt;
&lt;COL style="WIDTH: 479px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR style="BACKGROUND: #4f81bd"&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: #7ba1ce 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #7ba1ce 1pt solid; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Session Title&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #7ba1ce 1pt solid; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Time &amp;amp; Date&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #7ba1ce 1pt solid; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Session Code&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: #7ba1ce 1pt solid; BORDER-RIGHT: #7ba1ce 1pt solid"&gt;
&lt;P&gt;&lt;SPAN style="COLOR: white"&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="BACKGROUND: #d3e0ef"&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: #7ba1ce 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;&lt;STRONG&gt;SharePoint 2010 Based Document Assembly and Manipulation using Word Automation Services and Open XML&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;10/20/2009 10:30 AM &lt;/P&gt;
&lt;P&gt;@ Mandalay Bay H&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;SPC349&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: #7ba1ce 1pt solid"&gt;
&lt;P&gt;The Open XML Formats are the new default file formats for Word, Excel and PowerPoint (docx, xlsx, pptx). With the Open XML SDK, which provides a set of .NET APIs that allows developers to create and manipulate documents in the Open XML Formats, and the Office services available on SharePoint 2010 (Word Automation Services, which performs high-performance bulk document conversions, and Excel Services, which provides server-side support for spreadsheet calculation), developers can now build solutions for server environments without the need of the Office clients. With just a few lines of code you will be able to create rich solutions, like document assembly. Come and check out all the demos and free source code.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: #7ba1ce 1pt solid; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;&lt;STRONG&gt;Deep Dive Open XML and the Open XML SDK&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;10/20/2009 1:15 PM &lt;/P&gt;
&lt;P&gt;@ Mandalay Bay J&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: medium none"&gt;
&lt;P&gt;SPC402&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #7ba1ce 1pt solid; BORDER-LEFT: medium none; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: medium none; BORDER-RIGHT: #7ba1ce 1pt solid"&gt;
&lt;P&gt;This session will introduce you to Open XML and the tools you use to develop Office document solutions. Using Open XML you have the power to create and edit documents on the server without needing to resort to COM based Office automation. You will get a basic understanding of how to use Open XML for authoring documents, spreadsheets and presentations. You will learn how to leverage the Open XML SDK and other various tools to make your development life easier. After this session is complete you will know everything you need to get going with building document automation processes. Come and check out all the demos and free source code.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;Let me know if there are specific demos you guys would like to see and I'll try to work on getting them included. After my presentations, I will make available all my demos and source code on this blog. Besides the presentations, you will be able to find me at the Office client booth during the week of SPC and at the "Ask the Experts" event on Wednesday October 21. If you're at SPC do come by and say hello. I always look forward to hearing feedback from you guys at these conferences. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9905610" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Conferences" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Conferences/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /><category term="Office 2010" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx" /></entry><entry><title>Finding Open XML Errors with Open XML SDK Validation</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/09/24/finding-open-xml-errors-with-open-xml-sdk-validation.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/09/24/finding-open-xml-errors-with-open-xml-sdk-validation.aspx</id><published>2009-09-25T00:36:00Z</published><updated>2009-09-25T00:36:00Z</updated><content type="html">&lt;P&gt;In a previous post, I gave you an &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/08/27/announcing-the-release-of-the-august-2009-ctp-for-the-open-xml-sdk.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/08/27/announcing-the-release-of-the-august-2009-ctp-for-the-open-xml-sdk.aspx"&gt;overview of the functionality added to the Open XML SDK 2.0 August 2009 CTP&lt;/A&gt;. Today, I want to deep dive into the schema and semantic level validation support within the SDK. Specifically, I am going to show you guys the Open XML SDK code needed to actually validate your Open XML files. &lt;/P&gt;
&lt;P&gt;If you've played around with manipulating Open XML files there is a good chance at one point in time your resulting document was considered invalid or corrupt by the applications. You've probably even seen one of these dialogs: &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://zeyadrajabi.members.winisp.net/Validationimage001.png"&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://zeyadrajabi.members.winisp.net/Validationimage002.png"&gt;&lt;/P&gt;
&lt;P&gt;What do you do when you get into this state? A lot of the time the application error dialogs don't really help you debug the issue. Well, that's where the Open XML SDK can help you out. With just a few lines of code you can identify key pieces of information that tell you what the error is and where to find it within the package. Validation with the Open XML SDK 2.0 is accomplished via the &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;OpenXmlValidator&lt;/SPAN&gt; class. This class allows you to enumerate all the errors within a file, where each error is represented via the &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;ValidationErrorInfo &lt;/SPAN&gt;class. The &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: #2b91af; FONT-SIZE: 10pt"&gt;ValidationErrorInfo &lt;/SPAN&gt;class stores the following information: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;User friendly description of the error &lt;/LI&gt;
&lt;LI&gt;An XPath to the exact location of the error &lt;/LI&gt;
&lt;LI&gt;The part where this error exists &lt;/LI&gt;
&lt;LI&gt;Other elements or parts that are related to this error &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Here is a code snippet you can reuse to validate Word documents: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;try &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OpenXmlValidator&lt;/SPAN&gt; validator = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;OpenXmlValidator&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; count = 0; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;ValidationErrorInfo&lt;/SPAN&gt; error &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; validator.Validate(&lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt;.Open(&lt;SPAN style="COLOR: #a31515"&gt;"InvalidFile.docx"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;))) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;count++; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Error "&lt;/SPAN&gt; + count); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Description: "&lt;/SPAN&gt; + error.Description); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Path: "&lt;/SPAN&gt; + error.Path.XPath); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"Part: "&lt;/SPAN&gt; + error.Part.Uri); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"-------------------------------------------"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.ReadKey(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;catch&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;Exception&lt;/SPAN&gt; ex) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(ex.Message); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;The same code can be used to validate Excel and PowerPoint documents. All you need to do is change the Open method to be one of the following: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;ValidationErrorInfo&lt;/SPAN&gt; error &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; validator.Validate(&lt;SPAN style="COLOR: #2b91af"&gt;PresentationDocument&lt;/SPAN&gt;.Open(&lt;SPAN style="COLOR: #a31515"&gt;"InvalidFile.pptx"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;)))&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;or &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;ValidationErrorInfo&lt;/SPAN&gt; error &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; validator.Validate(&lt;SPAN style="COLOR: #2b91af"&gt;SpreadsheetDocument&lt;/SPAN&gt;.Open(&lt;SPAN style="COLOR: #a31515"&gt;"InvalidFile.xlsx"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;)))&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;Pretty simple stuff! If you want to jump straight into the code, feel free to download this solution &lt;A href="http://zeyadrajabi.members.winisp.net/sourcecode/Validation.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/Validation.zip"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Let's walk through an example of validating and fixing an example &lt;A href="http://zeyadrajabi.members.winisp.net/InvalidFile.docx" mce_href="http://zeyadrajabi.members.winisp.net/InvalidFile.docx"&gt;corrupt Word document&lt;/A&gt;. Given this corrupt document, the Open XML SDK detects the following errors: &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://zeyadrajabi.members.winisp.net/Validationimage003.png"&gt;&lt;/P&gt;
&lt;P&gt;Let's look at each of these errors. &lt;/P&gt;
&lt;H2&gt;Error 1 &lt;/H2&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;: The attribute 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:rsidR' has invalid value '006B4C'. The actual length according to datatype 'hexBinary' is not equal to the specified length. The expected length is 4. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Path&lt;/STRONG&gt;: /w:document[1]/w:body[1]/w:p[1] &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Part&lt;/STRONG&gt;: /word/document.xml &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Let's take a look at the xml within the main document part: &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://zeyadrajabi.members.winisp.net/Validationimage004.png"&gt;&lt;/P&gt;
&lt;P&gt;The error indicates that the length of the value for &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 10pt"&gt;rsidR &lt;/SPAN&gt;is not correct. We can fix this issue by changing the value to &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;00006B4C&lt;/SPAN&gt;. &lt;/P&gt;
&lt;H2&gt;Error 2 &lt;/H2&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;: Element 'DocumentFormat.OpenXml.Wordprocessing.Footnote' referenced by 'footnoteReference@id' does not exist in part '/word/footnotes.xml'. The reference value is '3'. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Path&lt;/STRONG&gt;: /w:document[1]/w:body[1]/w:p[6]/w:r[2]/w:footnoteReference[1] &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Part&lt;/STRONG&gt;: /word/document.xml &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Let's take a look at the xml within the main document part: &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://zeyadrajabi.members.winisp.net/Validationimage005.png"&gt;&lt;/P&gt;
&lt;P&gt;Let's take a look at the xml within the footnotes part: &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://zeyadrajabi.members.winisp.net/Validationimage006.png"&gt;&lt;/P&gt;
&lt;P&gt;The error indicates that there is a reference to a footnote using the value "&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;3&lt;/SPAN&gt;", but no such value exists in the footnotes part. Let's go ahead and change the &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: #a31515; FONT-SIZE: 10pt"&gt;footnoteReference&lt;/SPAN&gt; to have a value of "&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;2&lt;/SPAN&gt;". &lt;/P&gt;
&lt;H2&gt;Error 3 &lt;/H2&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;: Attribute 'id' should have unique value. Its current value '1' duplicates with others. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Path&lt;/STRONG&gt;: /w:endnotes[1]/w:endnote[4] &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Part&lt;/STRONG&gt;: /word/endnotes.xml &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Let's take a look at the xml within the endnotes part: &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://zeyadrajabi.members.winisp.net/Validationimage007.png"&gt;&lt;/P&gt;
&lt;P&gt;The error indicates that that more than one endnote specify the same &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 10pt"&gt;id &lt;/SPAN&gt;value. Let's go ahead and change the values to be unique. &lt;/P&gt;
&lt;H2&gt;End Result &lt;/H2&gt;
&lt;P&gt;After making these fixes we should be able to open the fixed document with no issues as shown below: &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://zeyadrajabi.members.winisp.net/Validationimage008.png"&gt;&lt;/P&gt;
&lt;P&gt;Try out the validation functionality and let us know what you think. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9899161" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Word" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Word/default.aspx" /><category term="Office 2007" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx" /><category term="Excel" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Excel/default.aspx" /><category term="PowerPoint" scheme="http://blogs.msdn.com/brian_jones/archive/tags/PowerPoint/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Code Samples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx" /><category term="WordprocessingML" scheme="http://blogs.msdn.com/brian_jones/archive/tags/WordprocessingML/default.aspx" /><category term="SpreadsheetML" scheme="http://blogs.msdn.com/brian_jones/archive/tags/SpreadsheetML/default.aspx" /><category term="Zeyad's SDK Examples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /><category term="Office 2010" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx" /></entry><entry><title>Open XML SDK Code Snippets</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/09/17/open-xml-sdk-code-snippets.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/09/17/open-xml-sdk-code-snippets.aspx</id><published>2009-09-17T22:44:00Z</published><updated>2009-09-17T22:44:00Z</updated><content type="html">&lt;P&gt;In my &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/08/27/announcing-the-release-of-the-august-2009-ctp-for-the-open-xml-sdk.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/08/27/announcing-the-release-of-the-august-2009-ctp-for-the-open-xml-sdk.aspx"&gt;previous post&lt;/A&gt;, I announced the release of the &lt;A href="http://go.microsoft.com/fwlink/?LinkId=127912" mce_href="http://go.microsoft.com/fwlink/?LinkId=127912"&gt;Open XML SDK August 2009 CTP&lt;/A&gt;. Today, I want to announce the release of the &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=78bea298-a3f9-44cf-bde0-b4f30dc986df&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=78bea298-a3f9-44cf-bde0-b4f30dc986df&amp;amp;displaylang=en"&gt;Open XML SDK code snippets&lt;/A&gt;. This package of code snippets provides over fifty reusable code samples, in both C# and VB.NET, which accomplish many common tasks involving Excel, PowerPoint, or Word documents. Looking back at the architecture diagram for the Open XML SDK 2.0, these code snippets are part of the high level helper functions: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Architecture diagram" src="http://zeyadrajabi.members.winisp.net/architecture.png"&gt;&lt;/P&gt;
&lt;P&gt;Erika Ehrli provided a quick summary on all the code snippets in the following &lt;A href="http://blogs.msdn.com/erikaehrli/archive/2009/08/28/open-xml-sdk-2-0-august-ctp-and-50-open-xml-code-samples.aspx" mce_href="http://blogs.msdn.com/erikaehrli/archive/2009/08/28/open-xml-sdk-2-0-august-ctp-and-50-open-xml-code-samples.aspx"&gt;post&lt;/A&gt;. &lt;/P&gt;
&lt;H2&gt;Using the Open XML SDK Code Snippets &lt;/H2&gt;
&lt;P&gt;Let's walk through a quick example of using the Open XML SDK code snippets. In this example, we are given a spreadsheet with a table of data and are asked to read and change a particular cell value. Here is a screenshot of the spreadsheet: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Spreadsheet example" src="http://zeyadrajabi.members.winisp.net/spread1.png"&gt;&lt;/P&gt;
&lt;P&gt;Let's say we are asked to read the value of C4 and then change the value from "Austin" to "Houston". &lt;/P&gt;
&lt;P&gt;Here is how you would accomplish this scenario using the Open XML SDK code snippets and the Open XML SDK 2.0: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a solution in Visual Studio 2008 &lt;/LI&gt;
&lt;LI&gt;Add references to the Open XML SDK 2.0 (DocumentFormat.OpenXml.dll) and WindowsBase.dll &lt;/LI&gt;
&lt;LI&gt;Enable the code snippets for your solution by following &lt;A href="http://msdn.microsoft.com/en-us/library/9ybhaktf.aspx" mce_href="http://msdn.microsoft.com/en-us/library/9ybhaktf.aspx"&gt;these steps&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;To read a cell value, add a new method to your solution based on the Open XML SDK code snippets. In particular, add the "&lt;STRONG&gt;Excel: Get cell value given row and column&lt;/STRONG&gt;" code snippet, which retrieves a cell value given its row and column numbers, or a row number and column name &lt;/LI&gt;
&lt;LI&gt;Use the following code to read and display the value for C4: 
&lt;DIV style="MARGIN-LEFT: 5pt"&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; c4Value = XLGetCellValueRowCol(&lt;SPAN style="COLOR: #a31515"&gt;"output.xlsx"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"Sheet1"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"C"&lt;/SPAN&gt;, 4); &lt;SPAN style="COLOR: #2b91af"&gt;Console&lt;/SPAN&gt;.WriteLine(&lt;SPAN style="COLOR: #a31515"&gt;"The value for C4 is: "&lt;/SPAN&gt; + c4Value);&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;To change a cell value, add a new method to your solution based on the "&lt;STRONG&gt;Excel: Insert string into cell&lt;/STRONG&gt;" code snippet, which given a document name, a worksheet name, a cell name, and a value, inserts text into the specified cell &lt;/LI&gt;
&lt;LI&gt;Use the following code to change the value of C4 to "Houston" &lt;/LI&gt;&lt;/OL&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;XLInsertStringIntoCell(&lt;SPAN style="COLOR: #a31515"&gt;"output.xlsx"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"Sheet1"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"C4"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;"Houston"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;At the end of step #7 we end up with the following Excel spreadsheet: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Spreadsheet end result" src="http://zeyadrajabi.members.winisp.net/spread2.png"&gt;&lt;/P&gt;
&lt;P&gt;Pretty easy with the code snippets! If you are interested in the full solution you can find it &lt;A href="http://zeyadrajabi.members.winisp.net/sourcecode/CodeSnippetExample.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/CodeSnippetExample.zip"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9896471" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Office 2007" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Code Samples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx" /><category term="SpreadsheetML" scheme="http://blogs.msdn.com/brian_jones/archive/tags/SpreadsheetML/default.aspx" /><category term="Zeyad's SDK Examples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /><category term="Office 2010" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx" /></entry><entry><title>Announcing the Release of the August 2009 CTP for the Open XML SDK</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/08/27/announcing-the-release-of-the-august-2009-ctp-for-the-open-xml-sdk.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/08/27/announcing-the-release-of-the-august-2009-ctp-for-the-open-xml-sdk.aspx</id><published>2009-08-27T19:21:00Z</published><updated>2009-08-27T19:21:00Z</updated><content type="html">&lt;P&gt;I'm really happy to announce the release of the &lt;A href="http://go.microsoft.com/fwlink/?LinkId=127912" mce_href="http://go.microsoft.com/fwlink/?LinkId=127912"&gt;3&lt;SUP&gt;rd&lt;/SUP&gt; CTP for the Open XML SDK 2.0 for Microsoft Office&lt;/A&gt;! So what did we do in this CTP? Well, there were three main improvements we made to the SDK: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Add semantic level validation support &lt;/LI&gt;
&lt;LI&gt;Add markup compatibility/extensibility support &lt;/LI&gt;
&lt;LI&gt;General improvements based on your feedback &lt;/LI&gt;&lt;/OL&gt;
&lt;H2&gt;Semantic Level Validation Support &lt;/H2&gt;
&lt;P&gt;Let's go back to the Open XML SDK architecture diagram I showed you when we first &lt;A href="http://blogs.msdn.com/brian_jones/archive/2008/10/06/open-xml-format-sdk-2-0.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/10/06/open-xml-format-sdk-2-0.aspx"&gt;announced the Open XML SDK&lt;/A&gt;: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/Announcingimage1.png" mce_src="http://zeyadrajabi.members.winisp.net/Announcingimage1.png"&gt; &lt;/P&gt;
&lt;P&gt;As mentioned in a &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/04/08/announcing-the-release-of-the-open-xml-sdk-version-2-april-2009-ctp.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/04/08/announcing-the-release-of-the-open-xml-sdk-version-2-april-2009-ctp.aspx"&gt;previous post&lt;/A&gt;, the April 2009 CTP of the Open XML SDK added schema level validation support for Office 2007 Open XML files. In the August 2009 CTP, one of the big things we added is semantic level validation support for Office 2007 Open XML files: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/Announcingimage2.png" mce_src="http://zeyadrajabi.members.winisp.net/Announcingimage2.png"&gt; &lt;/P&gt;
&lt;P&gt;Semantic level validation goes beyond restrictions or rules defined by schemas. Semantic level validation allows developers to validate files against restrictions defined within the prose of the Open XML documentation. These are restrictions, which cannot be expressed in an XSD language. &lt;/P&gt;
&lt;P&gt;Let's look at a semantic level restriction example. Specifically, let's look at the element &lt;EM&gt;endnote&lt;/EM&gt; (Section 17.11.2 of Part 1 in the &lt;A href="http://www.iso.org/iso/catalogue_detail?csnumber=51463" mce_href="http://www.iso.org/iso/catalogue_detail?csnumber=51463"&gt;ISO/IEC-29500 specification&lt;/A&gt;). In the standard, it states that the &lt;EM&gt;id&lt;/EM&gt; attribute of &lt;EM&gt;endnote&lt;/EM&gt;, "specifies a unique ID which shall be used to match the contents of a footnote or endnote to the associated footnote/endnote reference mark … If more than one footnote shares the same ID, then this document shall be considered non-conformant. If more than one endnote shares the same ID, then this document shall be considered non-conformant." As you can see, having more than one endnote with the same id value will result in a non-conformant document. This non-conformant document may not be interpreted properly by a consuming application, like Word. &lt;/P&gt;
&lt;P&gt;The Open XML SDK can now help you find these types of problems and will report the error to you by giving you the following information: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV&gt;User friendly description of the error &lt;/DIV&gt;
&lt;UL&gt;
&lt;LI&gt;In this case, imagine seeing the following error "Attribute 'id' should have unique value. Its current value '1' duplicates with others." &lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;An Xpath to the exact location of the error &lt;/DIV&gt;
&lt;UL&gt;
&lt;LI&gt;In this case, imagine seeing the following path "/w:endnotes[1]/w:endnote[4]," which indicates that the problem exists in the fourth endnote element &lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;The part where this error exists &lt;/DIV&gt;
&lt;UL&gt;
&lt;LI&gt;In this case, imagine seeing the following part information "DocumentFormat.OpenXml.Packaging.EndnotesPart" &lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;We hope that you can use this type of information to more easily find and fix problems. I will devote at least one blog post in the future to go into details on the validation functionality. &lt;/P&gt;
&lt;H2&gt;Markup Compatibility/Extensibility Support &lt;/H2&gt;
&lt;P&gt;As defined by the &lt;A href="http://www.iso.org/iso/catalogue_detail?csnumber=51461" mce_href="http://www.iso.org/iso/catalogue_detail?csnumber=51461"&gt;ISO/IEC-29500 specification&lt;/A&gt;, there are several ways to extend markup within the Open XML formats. Some of the extension mechanisms, like ignorable content and alternate content blocks, may result in differences within the XML tree structure of a document. Here is an example of markup that contains an alternate content block: &lt;/P&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:document&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;mc:Ignorable&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;w14 wp14&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:body&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:p&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;w:rsidR&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;00FA0A01&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;w:rsidRDefault&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;00AF5A8F&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 108pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:r&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:rPr&lt;SPAN style="COLOR: blue"&gt;/&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;mc:AlternateContent&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 216pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;mc:Choice&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;Requires&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;wps&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 252pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:drawing&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;…… &lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:drawing&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 216pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;mc:Choice&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;mc:Fallback&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 216pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:pict&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 252pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;v:roundrect&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;id&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Rounded Rectangle 1&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;o:spid&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;_x0000_s1026&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;style&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;position:absolute… &lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;arcsize&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;10923f&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;o:gfxdata&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;…&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;fillcolor&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;#4f81bd&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;strokecolor&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;#385d8a&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;strokeweight&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;2pt&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 252pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;v:textbox&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;style&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;mso-rotate-with-shape:t&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 252pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;v:roundrect&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 216pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:pict&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;mc:Fallback&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;mc:AlternateContent&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 108pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:r&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:p&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:sectPr&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;w:rsidR&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;00FA0A01&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;…… &lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:sectPr&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:body&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:document&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;In the example above, the expected child of the run element differs depending on the chosen alternate content choice. The fallback choice is what one would expect from a document created in Office 2007, while the choice requiring the wps namespace is from a document created in Office 2010. Imagine you are a solution developer working with Open XML who has deployed a solution that works perfectly on top of Office 2007 Open XML files. How would your solution work with files coming in from Office 2010? Specifically, would your solution work with documents that contain these types of extension mechanisms? &lt;/P&gt;
&lt;P&gt;As part of the August 2009 CTP we have added functionality that allows developers to abstract away some of the difficulty intrinsic with markup compatibility and extensibility. This feature allows you to preprocess the content of Open XML files based on specific Office versions. Using the example above, if we use the August CTP to open the document based on Office 2007 we will only see the following XML markup: &lt;/P&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:document&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:body&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:p&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;w:rsidR&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;00FA0A01&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;w:rsidRDefault&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;00AF5A8F&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 108pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:r&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:rPr&lt;SPAN style="COLOR: blue"&gt;/&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:pict&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;v:roundrect&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;id&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;Rounded Rectangle 1&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;o:spid&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;_x0000_s1026&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;style&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;position:absolute… &lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;arcsize&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;10923f&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;o:gfxdata&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;…&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;fillcolor&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;#4f81bd&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;strokecolor&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;#385d8a&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;strokeweight&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;2pt&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;v:textbox&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;style&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;mso-rotate-with-shape:t&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;v:roundrect&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:pict&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 108pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:r&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:p&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;&lt;SPAN style="COLOR: #a31515"&gt;w:sectPr&lt;SPAN style="COLOR: blue"&gt; &lt;SPAN style="COLOR: red"&gt;w:rsidR&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;00FA0A01&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;…… &lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:sectPr&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:body&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&amp;lt;/&lt;SPAN style="COLOR: #a31515"&gt;w:document&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;If your solution expected a pict element as a child of a run element, then your solution would work perfectly with this file. In other words, using this feature, solutions won't break when future versions of Office introduce new markup into the format. &lt;/P&gt;
&lt;H2&gt;General Improvements &lt;/H2&gt;
&lt;P&gt;First off we want to thank everyone for their feedback and suggestions! Based on your feedback we made the following big changes to the SDK: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;AutoSave&lt;/STRONG&gt;: By default, previous CTPs of the SDK forced you to perform a manual save for changes made to specific parts within the package. We have now introduced the concept of AutoSave, where changes would automatically be saved into the package, without the need to call Save() methods. For those not interested in this functionality, there is a way to turn off this feature &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Base Classes for CustomXml objects and Sdt objects&lt;/STRONG&gt;: The SDK currently has multiple classes to represent CustomXml and Sdt objects based on the different types of elements specified in the standard. The August 2009 CTP has introduced one base class for each of these objects in order to make it easier for you to develop solutions. In other words, your solution can now just work on the following two abstract classes: CustomXmlElement for CustomXml objects and SdtElement for Sdt objects &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Simple types for Boolean type attributes&lt;/STRONG&gt;: The standard specifies the concept of a simple type called ST_OnOff, which allows for values like "On", "Off", "True", "False", "0", and "1." We have updated the SDK to allow you to directly get/set such attributes using standard C# Boolean values. For example, you can now set attribute values to false or true. Without this enhancement you were forced to compare values using the enum BooleanValues &lt;/LI&gt;&lt;/UL&gt;
&lt;H2&gt;What's Next? &lt;/H2&gt;
&lt;P&gt;Our next task for the SDK is to add Office 2010 Office Open XML support. Expect to see another CTP in the next several months released with this functionality. Our goal is to be done with the Open XML SDK 2.0 around the same time as Office 2010 ships (date not public yet). &lt;/P&gt;
&lt;H2&gt;More Feedback Always Welcome &lt;/H2&gt;
&lt;P&gt;Please continue to send us your feedback, either on this blog or at our Microsoft Connect site for the Open XML SDK &lt;A href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=589" mce_href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=589"&gt;https://connect.microsoft.com/site/sitehome.aspx?SiteID=589&lt;/A&gt;. We look forward to hearing from you. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9887075" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Office 2007" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /><category term="Office 2010" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx" /></entry><entry><title>Native Code Open Packaging Convention APIs</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/08/19/native-code-open-packaging-convention-apis.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/08/19/native-code-open-packaging-convention-apis.aspx</id><published>2009-08-19T23:27:00Z</published><updated>2009-08-19T23:27:00Z</updated><content type="html">&lt;P&gt;In my &lt;A href="http://blogs.msdn.com/brian_jones/archive/2008/10/06/open-xml-format-sdk-2-0.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/10/06/open-xml-format-sdk-2-0.aspx"&gt;introduction post on the Open XML SDK&lt;/A&gt; I mentioned that the SDK is built on top of &lt;A href="http://msdn.microsoft.com/en-us/library/system.io.packaging.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.io.packaging.aspx"&gt;System.IO.Packaging&lt;/A&gt;. System.IO.Packaging is a set of APIs that are part of .NET 3.0, which allow developers to create and manipulate documents based on the Open Package Convention (OPC). Given that Open XML Formats are based on OPC, the SDK uses System.IO.Packaging APIs to open, edit, create, and save Open XML packages. &lt;/P&gt;
&lt;P&gt;Some of you have left comments on this blog and on the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/oxmlsdk/threads" mce_href="http://social.msdn.microsoft.com/Forums/en-US/oxmlsdk/threads"&gt;Open XML SDK forum&lt;/A&gt; asking about native code APIs to manipulate Open XML files. I have some good news for you guys. Included in &lt;A href="http://www.microsoft.com/windows/windows-7/default.aspx" mce_href="http://www.microsoft.com/windows/windows-7/default.aspx"&gt;Windows 7&lt;/A&gt; will be all new native code &lt;A href="http://msdn.microsoft.com/en-us/library/dd371623.aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd371623.aspx"&gt;Win32 Packaging&lt;/A&gt; APIs. For more information on this new API, check out the &lt;A href="http://blogs.msdn.com/opc/default.aspx" mce_href="http://blogs.msdn.com/opc/default.aspx"&gt;OPC team blog&lt;/A&gt;. In particular check out the post &lt;A href="http://blogs.msdn.com/opc/archive/2009/08/05/comparison-between-the-opc-managed-code-and-native-code-apis.aspx" mce_href="http://blogs.msdn.com/opc/archive/2009/08/05/comparison-between-the-opc-managed-code-and-native-code-apis.aspx"&gt;comparing the managed version of the API with the native code version&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9875929" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /></entry><entry><title>Adding Repeating Data to PowerPoint</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/08/13/adding-repeating-data-to-powerpoint.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/08/13/adding-repeating-data-to-powerpoint.aspx</id><published>2009-08-14T03:58:00Z</published><updated>2009-08-14T03:58:00Z</updated><content type="html">&lt;P&gt;In a previous post, I showed you how to &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/01/19/pushing-data-from-a-database-into-a-word-document.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/01/19/pushing-data-from-a-database-into-a-word-document.aspx"&gt;create a product catalog in a Word document using the Open XML SDK&lt;/A&gt;. I also showed you how to &lt;A href="http://blogs.msdn.com/brian_jones/archive/2008/11/18/creating-a-presentation-report-based-on-data.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/11/18/creating-a-presentation-report-based-on-data.aspx"&gt;make PowerPoint a reporting application based on data within a database&lt;/A&gt;. Today, I am going to show you how to create a product catalog in a PowerPoint deck using the Open XML SDK. One of the key things I am going to show you in this post is how to create repeating data within a table on a slide. &lt;/P&gt;
&lt;P&gt;If you want to jump straight into the code, feel free to download this solution &lt;A href="http://zeyadrajabi.members.winisp.net/sourcecode/ProductCatalog.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/ProductCatalog.zip"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;
&lt;OBJECT width=425 height=344&gt;&lt;PARAM NAME="movie" VALUE="http://www.youtube.com/v/eT2ASswr0kA&amp;amp;hl=en&amp;amp;fs=1"&gt;&lt;PARAM NAME="allowFullScreen" VALUE="true"&gt;&lt;PARAM NAME="allowscriptaccess" VALUE="always"&gt;
                                    
            &lt;embed src="http://www.youtube.com/v/eT2ASswr0kA&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash"
                allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/OBJECT&gt;&lt;/P&gt;
&lt;H2&gt;Scenario &lt;/H2&gt;
&lt;P&gt;Imagine a scenario where I'm a developer working for a fictional company called Adventure Works. In my company, we use a database to store our entire product inventory. The sales and marketing teams have asked me to build a report generation tool that is able to take the list of products and create a viewable presentation. In other words, these teams want to use a PowerPoint deck to showcase all our company's products. &lt;/P&gt;
&lt;H2&gt;Solution &lt;/H2&gt;
&lt;P&gt;Before I get into the details of my solution I want to state that I am using the freely available &lt;A href="http://msftdbprodsamples.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=18407" mce_href="http://msftdbprodsamples.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=18407"&gt;Adventure Works database&lt;/A&gt; built for SQL Server 2008. &lt;/P&gt;
&lt;P&gt;The scenario I listed above talks about reading product data and creating a report in the form of a presentation. The products in the database are organized into categories, like clothing or bikes, and subcategories, like mountain bikes or road bikes. To make viewing the resulting presentation easier I want to make sure my slides are also organized and separated based on categories. To accomplish this task, the first thing I need to do is create a presentation template that I can use for my solution. In this case, my presentation template will contain three slides: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Title slide – This slide represents the title of the presentation deck &lt;/LI&gt;
&lt;LI&gt;Template category section slide – This slide represents the divider that will separate different sections of my deck based on categories &lt;/LI&gt;
&lt;LI&gt;Template product table slide – This slide represents the table I will extend based on the products in my database &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;My presentation template will look like the following: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/081409_0056_AddingRepea1.png" mce_src="http://zeyadrajabi.members.winisp.net/081409_0056_AddingRepea1.png"&gt; &lt;/P&gt;
&lt;P&gt;Given this template, here is one way to automatically generate a PowerPoint deck based off data from a database: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Open up the template presentation via the Open XML SDK and access its main presentation part &lt;/LI&gt;
&lt;LI&gt;From the presentation part, access the two template slides (category section slide and product table slide) &lt;/LI&gt;
&lt;LI&gt;Connect to the Adventure Works database and query for the list of products sorted by category &lt;/LI&gt;
&lt;LI&gt;Go through every product returned in the query &lt;/LI&gt;
&lt;LI&gt;For every new category encountered, clone the template category section slide and change the placeholder text to be the actual category name &lt;/LI&gt;
&lt;LI&gt;Clone the template product table slide at the start of every new section or if the product table becomes too large and needs to be extended to the next slide &lt;/LI&gt;
&lt;LI&gt;For every product, add an image part to the slide and feed the image part with data from the database &lt;/LI&gt;
&lt;LI&gt;For every product, add a new row to the appropriate cloned table slide. These rows will contain five cells, where the first cell will contain a background image of the product, and the other four cells will contain text &lt;/LI&gt;
&lt;LI&gt;Delete the two template slides &lt;/LI&gt;
&lt;LI&gt;Save and close the presentation &lt;/LI&gt;&lt;/OL&gt;
&lt;H2&gt;The Code &lt;/H2&gt;
&lt;P&gt;I should note that this solution will reuse a bit of functionality and methods from my previous post on &lt;A href="http://blogs.msdn.com/brian_jones/archive/2008/11/18/creating-a-presentation-report-based-on-data.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2008/11/18/creating-a-presentation-report-based-on-data.aspx"&gt;creating a presentation report based on data&lt;/A&gt;. Specifically, I am going to reuse the following methods: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; CloneSlidePart(&lt;SPAN style="COLOR: #2b91af"&gt;PresentationPart&lt;/SPAN&gt; presentationPart, &lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; slideTemplate)&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;This method will be used to actually clone slide parts &lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; SwapPlaceholderText(&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; slidePart, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; placeholder, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; value)&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Times New Roman; FONT-SIZE: 12pt"&gt; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;This method will be used to swap placeholder text for a new value &lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; DeleteTemplateSlide(&lt;SPAN style="COLOR: #2b91af"&gt;PresentationPart&lt;/SPAN&gt; presentationPart, &lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; slideTemplate) &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Times New Roman; FONT-SIZE: 12pt"&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;This method will be used to delete the template slides. I extended this method to have an additional parameter in order to specify the relationship id of the part to be deleted. It seems that my previous post actually hardcoded the value in the method &lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;In addition to the three above methods, I will also reuse functionality from my previous post on &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/01/19/pushing-data-from-a-database-into-a-word-document.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/01/19/pushing-data-from-a-database-into-a-word-document.aspx"&gt;pushing data from a database into a Word document&lt;/A&gt;. Specifically, I am going to reuse the following method: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; CalculateImageEmus(&lt;SPAN style="COLOR: #2b91af"&gt;Bitmap&lt;/SPAN&gt; bitmap, &lt;SPAN style="COLOR: blue"&gt;out&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; widthInEmu, &lt;SPAN style="COLOR: blue"&gt;out&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; heightInEmu)&lt;/SPAN&gt; &lt;/DIV&gt;
&lt;OL&gt;
&lt;LI&gt;This method will be used to calculate image widths and heights in EMUs. The image height will be used to calculate the row height &lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Reusing these methods will actually make coding this solution a lot easier! &lt;/P&gt;
&lt;P&gt;The first couple of steps require us to open the presentation template and access the two template slide parts. Here is the code snippet used to accomplish this task: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;PresentationDocument&lt;/SPAN&gt; myPres = &lt;SPAN style="COLOR: #2b91af"&gt;PresentationDocument&lt;/SPAN&gt;.Open(&lt;SPAN style="COLOR: #a31515"&gt;"output.pptx"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;)) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;PresentationPart&lt;/SPAN&gt; presPart = myPres.PresentationPart; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; sectionSlidePart = (&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt;)presPart.GetPartById(&lt;SPAN style="COLOR: #a31515"&gt;"rId3"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; tableSlidePart = (&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt;)presPart.GetPartById(&lt;SPAN style="COLOR: #a31515"&gt;"rId4"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;... &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;The next step is to query the database to retrieve a list of products sorted by category. Here is the code snippet used to accomplish this task: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;AdventureWorksDataContext&lt;/SPAN&gt; db = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;AdventureWorksDataContext&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; productQuery = &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;from&lt;/SPAN&gt; p &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; db.Products &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;join&lt;/SPAN&gt; PM &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; db.ProductModels &lt;SPAN style="COLOR: blue"&gt;on&lt;/SPAN&gt; p.ProductModelID &lt;SPAN style="COLOR: blue"&gt;equals&lt;/SPAN&gt; PM.ProductModelID &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;join&lt;/SPAN&gt; PSC &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; db.ProductSubcategories &lt;SPAN style="COLOR: blue"&gt;on&lt;/SPAN&gt; p.ProductSubcategoryID &lt;SPAN style="COLOR: blue"&gt;equals&lt;/SPAN&gt; PSC.ProductSubcategoryID &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;join&lt;/SPAN&gt; PC &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; db.ProductCategories &lt;SPAN style="COLOR: blue"&gt;on&lt;/SPAN&gt; PSC.ProductCategoryID &lt;SPAN style="COLOR: blue"&gt;equals&lt;/SPAN&gt; PC.ProductCategoryID &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;orderby&lt;/SPAN&gt; PC.Name, PSC.Name &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;select&lt;/SPAN&gt; p;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;Now we should be able to go through the list of products. As described in the solution section, for every product we encounter in our query we may need to add a new category slide or a new product table slide. We will add a new category slide if we encounter a new category (remember we are sorting our products based on category). Here is the code snippet used to accomplish this task: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; section = &lt;SPAN style="COLOR: #a31515"&gt;""&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; product &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; productQuery) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; category = product.ProductSubcategory.ProductCategory.Name; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; subcategory = product.ProductSubcategory.Name; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; model = product.ProductModel.Name; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; productName = product.Name; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;decimal&lt;/SPAN&gt; price = &lt;SPAN style="COLOR: #2b91af"&gt;Math&lt;/SPAN&gt;.Round(product.ListPrice, 2); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (section != category) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; newSectionPart = CloneSlidePart(presPart, sectionSlidePart); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;SwapPlaceholderText(newSectionPart, &lt;SPAN style="COLOR: #a31515"&gt;"Section Title"&lt;/SPAN&gt;, category); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;section = category; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;overflow = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;... &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;We will add a new product table slide whenever we encounter the first product within a category or if adding a new row to the current slide's table would cause the table to be too high and off of the visible slide. Here is the code snippet used to accomplish this task: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 638px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;bool&lt;/SPAN&gt; overflow = &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;;&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; totalHeight = 0; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; current = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;foreach&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; product &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; productQuery) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;... &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (overflow) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;SlidePart&lt;/SPAN&gt; newTablePart = CloneSlidePart(presPart, tableSlidePart); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;SwapPlaceholderText(newTablePart, &lt;SPAN style="COLOR: #a31515"&gt;"Section"&lt;/SPAN&gt;, category); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;current = newTablePart; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;overflow = &lt;SPAN style="COLOR: blue"&gt;false&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;totalHeight = 0; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;} &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;... &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;Notice that I am using the Boolean value of overflow to indicate whether or not a table has too much content in it already. The next step is to add an image for every product we encounter. In addition, we need to calculate the height of the image so that we can keep track of how much content is in the current table. The height of the image will be used for the height of the added row. If the height becomes too large then we will need to make sure that overflow is set to &lt;SPAN style="FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 10pt"&gt;true&lt;/SPAN&gt;. Here is the code snippet used to accomplish this task: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 750px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; imageRel = &lt;SPAN style="COLOR: #a31515"&gt;"imageRelId"&lt;/SPAN&gt;; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; imageRelId = 1; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;...&lt;SPAN style="COLOR: #2b91af"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;ImagePart&lt;/SPAN&gt; imagePart = current.AddImagePart(&lt;SPAN style="COLOR: #2b91af"&gt;ImagePartType&lt;/SPAN&gt;.Gif, imageRel + imageRelId); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;imagePart.FeedData(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MemoryStream&lt;/SPAN&gt;(product.ProductProductPhotos.First().ProductPhoto.LargePhoto.ToArray())); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: green; FONT-SIZE: 10pt"&gt;// We need to know the proper dimensions of the image in Emus &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Bitmap&lt;/SPAN&gt; bitmap = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Bitmap&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MemoryStream&lt;/SPAN&gt;(product.ProductProductPhotos.First().ProductPhoto.LargePhoto.ToArray())); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;CalculateImageEmus(bitmap, &lt;SPAN style="COLOR: blue"&gt;out&lt;/SPAN&gt; widthInEmu, &lt;SPAN style="COLOR: blue"&gt;out&lt;/SPAN&gt; heightInEmu); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;totalHeight += heightInEmu; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (totalHeight &amp;gt; 4000000) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;overflow = &lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;The next step is to add a new table row that contains five cells. The first cell is going to include the product image as a background image in the cell and the other four cells will contain text. Here is the code snippet used to create the new row: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 667px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;A.&lt;SPAN style="COLOR: #2b91af"&gt;Table&lt;/SPAN&gt; tbl = current.Slide.Descendants&amp;lt;A.&lt;SPAN style="COLOR: #2b91af"&gt;Table&lt;/SPAN&gt;&amp;gt;().First(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;A.&lt;SPAN style="COLOR: #2b91af"&gt;TableRow&lt;/SPAN&gt; tr = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TableRow&lt;/SPAN&gt;(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;tr.Height = heightInEmu; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;tr.Append(CreateDrawingCell(imageRel + imageRelId)); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;tr.Append(CreateTextCell(category)); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;tr.Append(CreateTextCell(subcategory)); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;tr.Append(CreateTextCell(model)); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;tr.Append(CreateTextCell(price.ToString())); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;tbl.Append(tr); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;imageRelId++;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;Note that variable "A" refers to &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; A = DocumentFormat.OpenXml.Drawing;&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;I created two methods to create these two types of table cells. Here is the code snippet used to create a text cell: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 667px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TableCell&lt;/SPAN&gt; CreateTextCell(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; text) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;A.&lt;SPAN style="COLOR: #2b91af"&gt;TableCell&lt;/SPAN&gt; tc = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TableCell&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TextBody&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;BodyProperties&lt;/SPAN&gt;(), &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;Paragraph&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;Run&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 216pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;Text&lt;/SPAN&gt;(text)))), &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TableCellProperties&lt;/SPAN&gt;()); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; tc; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;Here is the code snippet used to create an image cell: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 667px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;static&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TableCell&lt;/SPAN&gt; CreateDrawingCell(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; relId) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;{ &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;A.&lt;SPAN style="COLOR: #2b91af"&gt;TableCell&lt;/SPAN&gt; tc = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TableCell&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TextBody&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;BodyProperties&lt;/SPAN&gt;(), &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;Paragraph&lt;/SPAN&gt;()), &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 144pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;TableCellProperties&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;BlipFill&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 216pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;Blip&lt;/SPAN&gt;() { Embed = relId }, &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 252pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;Stretch&lt;/SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 288pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; A.&lt;SPAN style="COLOR: #2b91af"&gt;FillRectangle&lt;/SPAN&gt;())))); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; tc; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;Almost done! The last step is to delete the two template slides. Here is the code snippet used to accomplish this task: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 667px"&gt;&lt;/COLGROUP&gt;
&lt;TBODY vAlign=top&gt;
&lt;TR&gt;
&lt;TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: black 0.5pt solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 7px; PADDING-RIGHT: 7px; BORDER-TOP: black 0.5pt solid; BORDER-RIGHT: black 0.5pt solid; PADDING-TOP: 1px" vAlign=center&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;DeleteTemplateSlide(presPart, sectionSlidePart, &lt;SPAN style="COLOR: #a31515"&gt;"rId3"&lt;/SPAN&gt;); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;DeleteTemplateSlide(presPart, tableSlidePart, &lt;SPAN style="COLOR: #a31515"&gt;"rId4"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;H2&gt;End Result &lt;/H2&gt;
&lt;P&gt;Running this code I end up with a presentation that has over one hundred slides. &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/081409_0056_AddingRepea2.png" mce_src="http://zeyadrajabi.members.winisp.net/081409_0056_AddingRepea2.png"&gt; &lt;/P&gt;
&lt;P&gt;Here is another view of the output: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/081409_0056_AddingRepea3.png" mce_src="http://zeyadrajabi.members.winisp.net/081409_0056_AddingRepea3.png"&gt; &lt;/P&gt;
&lt;P&gt;Pretty cool stuff. The best part about this solution is that a designer can easily change the look of the template and still have this solution work as expected. For example, here is the output after the template design has been changed (same code running): &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/081409_0056_AddingRepea4.png" mce_src="http://zeyadrajabi.members.winisp.net/081409_0056_AddingRepea4.png"&gt; &lt;/P&gt;
&lt;P&gt;I should also note that all the screenshots above were taken with Office 2010. In other words, this solution works in Office 2007 and Office 2010. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9869117" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Office 2007" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx" /><category term="PowerPoint" scheme="http://blogs.msdn.com/brian_jones/archive/tags/PowerPoint/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Code Samples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx" /><category term="Zeyad's SDK Examples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /><category term="Office 2010" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx" /></entry><entry><title>Office Extensibility Blog Now Offered in Russian</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/08/10/office-extensibility-blog-now-offered-in-russian.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/08/10/office-extensibility-blog-now-offered-in-russian.aspx</id><published>2009-08-10T22:06:00Z</published><updated>2009-08-10T22:06:00Z</updated><content type="html">&lt;P&gt;I wanted to pass along some really exciting news. Brian Jones' blog is now available in Russian! Check it out here: &lt;A href="http://blogs.msdn.com/brian_jones_ru/" mce_href="http://blogs.msdn.com/brian_jones_ru/"&gt;http://blogs.msdn.com/brian_jones_ru/&lt;/A&gt;. Our plan is to continue localizing this blog into Russian so that we can share all the Office 2010 extensibility goodness to more people. Let us know if you want to see other Office blogs get localized to Russian as well. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9863460" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author></entry><entry><title>The Open XML SDK and Fluent UI Extensibility</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/brian_jones/archive/2009/08/03/the-open-xml-sdk-and-fluent-ui-extensibility.aspx" /><id>http://blogs.msdn.com/brian_jones/archive/2009/08/03/the-open-xml-sdk-and-fluent-ui-extensibility.aspx</id><published>2009-08-03T19:05:00Z</published><updated>2009-08-03T19:05:00Z</updated><content type="html">&lt;p&gt;Fluent UI, or the Ribbon, was introduced as part of Office 2007 as a replacement of the previous system of toolbars and menus. The Fluent UI technology, like the Open XML formats, is based on xml, which allows for a much richer extensibility story for developers. In Erika Ehril's blog &lt;a href="http://blogs.msdn.com/erikaehrli/archive/2009/07/22/get-started-resources-for-fluent-ui-extensibility-download-the-new-office-developer-resources-ribbon-tab.aspx" mce_href="http://blogs.msdn.com/erikaehrli/archive/2009/07/22/get-started-resources-for-fluent-ui-extensibility-download-the-new-office-developer-resources-ribbon-tab.aspx"&gt;post&lt;/a&gt; she described several tools and resources related to Fluent UI extensibility. I wanted to take this opportunity to extend her post by showing you how the Open XML SDK can be used to extend or actually control custom UI within documents. 
&lt;/p&gt;
&lt;p&gt;As is the case with other features in Open XML files, the &lt;a href="http://go.microsoft.com/fwlink/?LinkId=127912" mce_href="http://go.microsoft.com/fwlink/?LinkId=127912"&gt;Open XML SDK 2.0 for Microsoft Office&lt;/a&gt; supports Fluent UI through &lt;a href="http://msdn.microsoft.com/en-us/library/documentformat.openxml.packaging.ribbonextensibilitypart%28office.14%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/documentformat.openxml.packaging.ribbonextensibilitypart(office.14).aspx"&gt;strongly typed access to the custom UI xml part&lt;/a&gt; as well &lt;a href="http://msdn.microsoft.com/en-us/library/documentformat.openxml.office.customui%28office.14%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/documentformat.openxml.office.customui(office.14).aspx"&gt;strongly typed access to the underlying xml&lt;/a&gt; contained within the custom UI xml part. In other words, you can easily add, remove or modify custom UI for a particular document or set of documents using the SDK. In today's post, I am going to show you how to add custom UI to a set of documents within a directory. 
&lt;/p&gt;
&lt;p&gt;If you want to jump straight into the code, feel free to download this solution &lt;a href="http://zeyadrajabi.members.winisp.net/sourcecode/DeployCustomUI.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/DeployCustomUI.zip"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/ci3J9w5iOIg&amp;amp;hl=en&amp;amp;fs=1"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/ci3J9w5iOIg&amp;amp;hl=en&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/object&gt;&lt;/p&gt;
&lt;h2&gt;Scenario
&lt;/h2&gt;
&lt;p&gt;Imagine a scenario where I would like to programmatically add custom UI to a set of documents based on custom UI within a specific template. These documents can exist within a directory or a SharePoint library. In this scenario, my template is going to contain the same custom UI as designed by Frank Rice in his &lt;a href="http://blogs.msdn.com/frice/archive/2009/07/16/the-office-developer-resources-ribbon-ui-add-in.aspx" mce_href="http://blogs.msdn.com/frice/archive/2009/07/16/the-office-developer-resources-ribbon-ui-add-in.aspx"&gt;Office developer resources ribbon UI addin blog post&lt;/a&gt;. For the sake of this example, let's say I am starting with the following Word document as my template:
&lt;/p&gt;
&lt;p&gt;&lt;img src="http://zeyadrajabi.members.winisp.net/080309_1604_TheOpenXMLS1.png" mce_src="http://zeyadrajabi.members.winisp.net/080309_1604_TheOpenXMLS1.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;This custom UI provides a tab called Office Developer Resources, which contains commands that take you to specific web sites. The code behind these commands is actually contained within macros within the file. In order to add this custom UI to other documents we need to copy over the custom UI as well as the macros that power those commands. 
&lt;/p&gt;
&lt;h2&gt;The Solution
&lt;/h2&gt;
&lt;p&gt;To add custom UI to a set of documents we can take the following actions:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go through all files within a specific directory
&lt;/li&gt;
&lt;li&gt;If a file is a macro-free document then convert the document to a macro-enabled document
&lt;/li&gt;
&lt;li&gt;Open the template file using the Open XML SDK
&lt;/li&gt;
&lt;li&gt;Grab the ribbon extensibility part (contains the custom UI)
&lt;/li&gt;
&lt;li&gt;Grab the VBA project part (contains the macros)
&lt;/li&gt;
&lt;li&gt;&lt;div&gt;Open the converted file (or the original file if it was a macro-enabled file) and import both the ribbon and macro parts
&lt;/div&gt;
&lt;ol&gt;
&lt;/ol&gt;&lt;ul&gt;&lt;li&gt;The file can only contain one instance of each part so be sure to remove preexisting ribbon and macro parts from the file
&lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Note that the steps outlined above are just one method to accomplish this scenario. Another more practical use of this solution is to go through a list of files contained within a SharePoint library instead of a directory on disk. 
&lt;/p&gt;
&lt;h2&gt;The Code
&lt;/h2&gt;
&lt;p&gt;The first step as outlined in the solution section above requires us to go through a directory of files. Here is the code snippet to accomplish this task:
&lt;/p&gt;
&lt;div&gt;
&lt;table style="background: rgb(219, 229, 241) none repeat scroll 0% 0%; border-collapse: collapse; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 638px;"&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;
&lt;tr&gt;
&lt;td style="border: 0.5pt solid black; padding: 1px 7px;" valign="middle"&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt; newFileName = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] files = &lt;span style="color: rgb(43, 145, 175);"&gt;Directory&lt;/span&gt;.GetFiles(&lt;span style="color: rgb(163, 21, 21);"&gt;@"D:\Open XML SDK demos\Word\DeployCustomUI\DeployCustomUI\bin\Debug\Files"&lt;/span&gt;);
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: blue;"&gt;string&lt;/span&gt; filename &lt;span style="color: blue;"&gt;in&lt;/span&gt; files)
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (filename.EndsWith(&lt;span style="color: rgb(163, 21, 21);"&gt;".docx"&lt;/span&gt;))
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;newFileName = ChangeDocumentType(filename);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;else&lt;/span&gt;
								&lt;span style="color: blue;"&gt;if&lt;/span&gt; (filename.EndsWith(&lt;span style="color: rgb(163, 21, 21);"&gt;".docm"&lt;/span&gt;))
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;newFileName = filename;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;ImportCustomUI(templateFile, newFileName);
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;If a file in the directory turns out to be a macro-free file we need to change the document type to be a macro-enabled file. Here is the code snippet used to accomplish this task: 
&lt;/p&gt;
&lt;div&gt;
&lt;table style="background: rgb(219, 229, 241) none repeat scroll 0% 0%; border-collapse: collapse; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 638px;"&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;
&lt;tr&gt;
&lt;td style="border: 0.5pt solid black; padding: 1px 7px;" valign="middle"&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt;
								&lt;span style="color: blue;"&gt;string&lt;/span&gt; ChangeDocumentType(&lt;span style="color: blue;"&gt;string&lt;/span&gt; filename)
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;WordprocessingDocument&lt;/span&gt; myDoc = &lt;span style="color: rgb(43, 145, 175);"&gt;WordprocessingDocument&lt;/span&gt;.Open(filename, &lt;span style="color: blue;"&gt;true&lt;/span&gt;))
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{ 
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;myDoc.ChangeDocumentType(&lt;span style="color: rgb(43, 145, 175);"&gt;WordprocessingDocumentType&lt;/span&gt;.MacroEnabledDocument);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}      
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;     
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt; newFileName = &lt;span style="color: rgb(43, 145, 175);"&gt;Path&lt;/span&gt;.GetDirectoryName(filename) + &lt;span style="color: rgb(163, 21, 21);"&gt;@"\"&lt;/span&gt; + &lt;span style="color: rgb(43, 145, 175);"&gt;Path&lt;/span&gt;.GetFileNameWithoutExtension(filename) + &lt;span style="color: rgb(163, 21, 21);"&gt;"(was docx).docm"&lt;/span&gt;;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;File&lt;/span&gt;.Move(filename, newFileName);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;File&lt;/span&gt;.Delete(filename);           
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; newFileName;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;Notice how the Open XML SDK provides functionality to switch document types. At this point we are ready to import our custom UI from our template into our files within the directory. Below is the code snippet necessary to grab the custom UI and vba project parts from the template document:
&lt;/p&gt;
&lt;div&gt;
&lt;table style="background: rgb(219, 229, 241) none repeat scroll 0% 0%; border-collapse: collapse; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 638px;"&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;
&lt;tr&gt;
&lt;td style="border: 0.5pt solid black; padding: 1px 7px;" valign="middle"&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt;
								&lt;span style="color: blue;"&gt;void&lt;/span&gt; ImportCustomUI(&lt;span style="color: blue;"&gt;string&lt;/span&gt; templateFile, &lt;span style="color: blue;"&gt;string&lt;/span&gt; outputFile)
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;WordprocessingDocument&lt;/span&gt; myDoc = &lt;span style="color: rgb(43, 145, 175);"&gt;WordprocessingDocument&lt;/span&gt;.Open(templateFile, &lt;span style="color: blue;"&gt;true&lt;/span&gt;))
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MainDocumentPart&lt;/span&gt; mainPart = myDoc.MainDocumentPart;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;RibbonExtensibilityPart&lt;/span&gt; customRibbonPart =
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;myDoc.GetPartsOfType&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;RibbonExtensibilityPart&lt;/span&gt;&amp;gt;().First();
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;ExtendedPart&lt;/span&gt; vbaPart = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;IdPartPair&lt;/span&gt; partPair &lt;span style="color: blue;"&gt;in&lt;/span&gt; mainPart.Parts)
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (partPair.OpenXmlPart.RelationshipType == &lt;span style="color: rgb(163, 21, 21);"&gt;"http://schemas.microsoft.com/office/2006/relationships/vbaProject"&lt;/span&gt;)
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 144pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;vbaPart = (&lt;span style="color: rgb(43, 145, 175);"&gt;ExtendedPart&lt;/span&gt;)partPair.OpenXmlPart;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 144pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;break&lt;/span&gt;;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;AddCustomUIParts(outputFile, customRibbonPart, vbaPart);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;Now that we have the two parts from our template file we are ready to import them into our output file. Below is the code snippet necessary to accomplish this task: 
&lt;/p&gt;
&lt;div&gt;
&lt;table style="background: rgb(219, 229, 241) none repeat scroll 0% 0%; border-collapse: collapse; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 750px;"&gt;&lt;/colgroup&gt;&lt;tbody valign="top"&gt;
&lt;tr&gt;
&lt;td style="border: 0.5pt solid black; padding: 1px 7px;" valign="middle"&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt;
								&lt;span style="color: blue;"&gt;void&lt;/span&gt; AddCustomUIParts(&lt;span style="color: blue;"&gt;string&lt;/span&gt; filename, &lt;span style="color: rgb(43, 145, 175);"&gt;RibbonExtensibilityPart&lt;/span&gt; customRibbonPart, &lt;span style="color: rgb(43, 145, 175);"&gt;ExtendedPart&lt;/span&gt; vbaPart)
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;WordprocessingDocument&lt;/span&gt; myDoc = &lt;span style="color: rgb(43, 145, 175);"&gt;WordprocessingDocument&lt;/span&gt;.Open(filename, &lt;span style="color: blue;"&gt;true&lt;/span&gt;))
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;MainDocumentPart&lt;/span&gt; mainPart = myDoc.MainDocumentPart;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (myDoc.GetPartsCountOfType&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;RibbonExtensibilityPart&lt;/span&gt;&amp;gt;() &amp;gt; 0)
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;myDoc.DeletePart(myDoc.GetPartsOfType&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;RibbonExtensibilityPart&lt;/span&gt;&amp;gt;().First());
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;myDoc.AddPart&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;RibbonExtensibilityPart&lt;/span&gt;&amp;gt;(customRibbonPart);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;ExtendedPart&lt;/span&gt; extendedPart = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;IdPartPair&lt;/span&gt; partPair &lt;span style="color: blue;"&gt;in&lt;/span&gt; mainPart.Parts)
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (partPair.OpenXmlPart.RelationshipType ==
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 144pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;"http://schemas.microsoft.com/office/2006/relationships/vbaProject"&lt;/span&gt;)
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;{
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 144pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;extendedPart = (&lt;span style="color: rgb(43, 145, 175);"&gt;ExtendedPart&lt;/span&gt;)partPair.OpenXmlPart;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 144pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;break&lt;/span&gt;;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (extendedPart != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;mainPart.DeletePart(extendedPart);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (vbaPart != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 108pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;mainPart.AddPart&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;ExtendedPart&lt;/span&gt;&amp;gt;(vbaPart);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;Notice in the code above that I am removing any previous custom UI or vba part within the output document. Instead of deleting these parts I could have chosen to do some kind of merge, although that approach would have been more difficult. 
&lt;/p&gt;
&lt;h2&gt;End Result
&lt;/h2&gt;
&lt;p&gt;Running this code I should end up with a directory full of macro-enabled files that all have custom UI enabled. Here is a screenshot of one of my documents, which has the imported custom UI:
&lt;/p&gt;
&lt;p&gt;&lt;img src="http://zeyadrajabi.members.winisp.net/080309_1604_TheOpenXMLS2.png" mce_src="http://zeyadrajabi.members.winisp.net/080309_1604_TheOpenXMLS2.png" alt=""&gt;
	&lt;/p&gt;
&lt;p&gt;Zeyad Rajabi&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9856335" width="1" height="1"&gt;</content><author><name>BrianJones</name><uri>http://blogs.msdn.com/members/BrianJones.aspx</uri></author><category term="Office 2007" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx" /><category term="OpenXML Developers" scheme="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx" /><category term="Code Samples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx" /><category term="Zeyad's SDK Examples" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx" /><category term="Open XML SDK" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx" /><category term="Office 2010" scheme="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx" /></entry></feed>