<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Brian Jones &amp; Zeyad Rajabi: Office Solutions</title><link>http://blogs.msdn.com/brian_jones/default.aspx</link><description>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. </description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Open XML SDK Sessions at the Professional Developers Conference (PDC)</title><link>http://blogs.msdn.com/brian_jones/archive/2009/11/10/open-xml-sdk-sessions-at-the-professional-developers-conference-pdc.aspx</link><pubDate>Tue, 10 Nov 2009 23:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9920514</guid><dc:creator>BrianJones</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9920514.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9920514</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Conferences/default.aspx">Conferences</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category></item><item><title>Open XML and Office Services </title><link>http://blogs.msdn.com/brian_jones/archive/2009/11/03/open-xml-and-office-services.aspx</link><pubDate>Tue, 03 Nov 2009 20:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9916952</guid><dc:creator>BrianJones</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9916952.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9916952</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Word/default.aspx">Word</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Excel/default.aspx">Excel</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/PDF/default.aspx">PDF</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category></item><item><title>Migrating your custom solutions to Office 14</title><link>http://blogs.msdn.com/brian_jones/archive/2009/10/22/migrating-your-custom-solutions-to-office-14.aspx</link><pubDate>Fri, 23 Oct 2009 00:11:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9911774</guid><dc:creator>BrianJones</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9911774.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9911774</wfw:commentRss><description>&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;</description></item><item><title>Open XML SDK Demos Shown at the SharePoint Conference (SPC)</title><link>http://blogs.msdn.com/brian_jones/archive/2009/10/21/demos-shown-at-the-sharepoint-conference-spc.aspx</link><pubDate>Thu, 22 Oct 2009 04:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9911107</guid><dc:creator>BrianJones</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9911107.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9911107</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Conferences/default.aspx">Conferences</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx">Zeyad's SDK Examples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category></item><item><title>Open XML SDK Sessions at the SharePoint Conference (SPC)</title><link>http://blogs.msdn.com/brian_jones/archive/2009/10/09/open-xml-sdk-sessions-at-the-sharepoint-conference-spc.aspx</link><pubDate>Fri, 09 Oct 2009 23:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9905610</guid><dc:creator>BrianJones</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9905610.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9905610</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Conferences/default.aspx">Conferences</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Finding Open XML Errors with Open XML SDK Validation</title><link>http://blogs.msdn.com/brian_jones/archive/2009/09/24/finding-open-xml-errors-with-open-xml-sdk-validation.aspx</link><pubDate>Fri, 25 Sep 2009 00:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9899161</guid><dc:creator>BrianJones</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9899161.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9899161</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Word/default.aspx">Word</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Excel/default.aspx">Excel</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/PowerPoint/default.aspx">PowerPoint</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/WordprocessingML/default.aspx">WordprocessingML</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/SpreadsheetML/default.aspx">SpreadsheetML</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx">Zeyad's SDK Examples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Open XML SDK Code Snippets</title><link>http://blogs.msdn.com/brian_jones/archive/2009/09/17/open-xml-sdk-code-snippets.aspx</link><pubDate>Thu, 17 Sep 2009 22:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9896471</guid><dc:creator>BrianJones</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9896471.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9896471</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/SpreadsheetML/default.aspx">SpreadsheetML</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx">Zeyad's SDK Examples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Announcing the Release of the August 2009 CTP for the Open XML SDK</title><link>http://blogs.msdn.com/brian_jones/archive/2009/08/27/announcing-the-release-of-the-august-2009-ctp-for-the-open-xml-sdk.aspx</link><pubDate>Thu, 27 Aug 2009 19:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9887075</guid><dc:creator>BrianJones</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9887075.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9887075</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Native Code Open Packaging Convention APIs</title><link>http://blogs.msdn.com/brian_jones/archive/2009/08/19/native-code-open-packaging-convention-apis.aspx</link><pubDate>Wed, 19 Aug 2009 23:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9875929</guid><dc:creator>BrianJones</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9875929.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9875929</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category></item><item><title>Adding Repeating Data to PowerPoint</title><link>http://blogs.msdn.com/brian_jones/archive/2009/08/13/adding-repeating-data-to-powerpoint.aspx</link><pubDate>Fri, 14 Aug 2009 03:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9869117</guid><dc:creator>BrianJones</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9869117.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9869117</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/PowerPoint/default.aspx">PowerPoint</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx">Zeyad's SDK Examples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Office Extensibility Blog Now Offered in Russian</title><link>http://blogs.msdn.com/brian_jones/archive/2009/08/10/office-extensibility-blog-now-offered-in-russian.aspx</link><pubDate>Mon, 10 Aug 2009 22:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9863460</guid><dc:creator>BrianJones</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9863460.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9863460</wfw:commentRss><description>&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;</description></item><item><title>The Open XML SDK and Fluent UI Extensibility</title><link>http://blogs.msdn.com/brian_jones/archive/2009/08/03/the-open-xml-sdk-and-fluent-ui-extensibility.aspx</link><pubDate>Mon, 03 Aug 2009 19:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9856335</guid><dc:creator>BrianJones</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9856335.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9856335</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2007/default.aspx">Office 2007</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx">Zeyad's SDK Examples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Embedding Any File Type, Like PDF, in an Open XML File</title><link>http://blogs.msdn.com/brian_jones/archive/2009/07/21/embedding-any-file-type-like-pdf-in-an-open-xml-file.aspx</link><pubDate>Tue, 21 Jul 2009 22:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9843756</guid><dc:creator>BrianJones</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9843756.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9843756</wfw:commentRss><description>
&lt;p&gt;In my last post, I showed you guys &lt;a href="http://blogs.msdn.com/brian_jones/archive/2009/06/30/embedding-an-open-xml-file-in-another-open-xml-file.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/06/30/embedding-an-open-xml-file-in-another-open-xml-file.aspx"&gt;how to embed an Excel spreadsheet within a Word document&lt;/a&gt; without the need to invoke an OLE Server. In today's post I am going to show you how to embed any file in an Open XML file. Specifically, I am going to show you how to embed a PDF file into a Word document. Note that this approach requires you to invoke an OLE Server to embed the file into an Open XML file. 
&lt;/p&gt;

&lt;p&gt;My post will talk about using &lt;a href="http://go.microsoft.com/fwlink/?LinkId=127912" mce_href="http://go.microsoft.com/fwlink/?LinkId=127912"&gt;version 2 of the SDK&lt;/a&gt;. 
&lt;/p&gt;

&lt;p&gt;If you just want to jump straight into the code, feel free to download this solution &lt;a href="http://zeyadrajabi.members.winisp.net/sourcecode/PackageNonOfficeFiles.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/PackageNonOfficeFiles.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/qRzK035M4xI&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/qRzK035M4xI&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;&amp;lt;
&lt;h2&gt;Solution
&lt;/h2&gt;
&lt;p&gt;To embed a PDF file into a Word document we can take the following actions:
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a template in Word that contains a content control that will be used to demarcate the region where the embedded object will be inserted
&lt;/li&gt;

&lt;li&gt;Open up the Word document via the Open XML SDK and access its main document part
&lt;/li&gt;

&lt;li&gt;Invoke the OLE server application associated with PDF files to create an &lt;a href="http://msdn.microsoft.com/en-us/library/aa380015.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa380015.aspx"&gt;IStorage&lt;/a&gt; and an image of the embedded object
&lt;/li&gt;

&lt;li&gt;Add an image part to the document
&lt;/li&gt;

&lt;li&gt;Feed the data from the generated image into the added image part
&lt;/li&gt;

&lt;li&gt;Add an embedded object part to the document
&lt;/li&gt;

&lt;li&gt;Feed the data from the generated IStorage into the embedded object part
&lt;/li&gt;

&lt;li&gt;Determine the prog id associated with the application associated with PDF files
&lt;/li&gt;

&lt;li&gt;Create a paragraph that contains the embedded object 
&lt;/li&gt;

&lt;li&gt;Locate the content control that will contain the embedded object
&lt;/li&gt;

&lt;li&gt;Swap out the content control for the newly created paragraph
&lt;/li&gt;

&lt;li&gt;Save changes made to the Word document
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note that the steps outlined above are just one method to accomplish this scenario. The steps above are very similar to my previous post showing you &lt;a href="http://blogs.msdn.com/brian_jones/archive/2009/06/30/embedding-an-open-xml-file-in-another-open-xml-file.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/06/30/embedding-an-open-xml-file-in-another-open-xml-file.aspx"&gt;how to embed an Excel spreadsheet within a Word document&lt;/a&gt;. The main difference is in how we go about adding the embedded object to the Word document. No application, at least on my computer, has written out a subkey IPersistStorageType under HKCR\CLSID\{Apps_OLE_Storage_CLSID} for PDF files, which means there is no way for us to know the required structure of an IStorage containing a PDF file. Instead we are required to rely on the OLE server application associated with PDF files to generate the appropriate IStorage. 
&lt;/p&gt;

&lt;p&gt;For the sake of this example, let's say I am starting with the following Word document: 
&lt;/p&gt;

&lt;p&gt;&lt;img src="http://zeyadrajabi.members.winisp.net/Embed1.png" alt="Embed1"&gt;&lt;/p&gt;

&lt;p&gt;This document contains a content control, named "EmbedObject," which will contain my embedded object. In addition, let's say I have the following PDF file I wish to embed:
&lt;/p&gt;

&lt;p&gt;&lt;img src="http://zeyadrajabi.members.winisp.net/Embed2.png" alt="Embed2"&gt;&lt;/p&gt;
&lt;h2&gt;The Code
&lt;/h2&gt;
&lt;p&gt;As mentioned in &lt;a href="http://blogs.msdn.com/brian_jones/archive/2009/06/30/embedding-an-open-xml-file-in-another-open-xml-file.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/06/30/embedding-an-open-xml-file-in-another-open-xml-file.aspx"&gt;my previous post&lt;/a&gt;, embedding an object in a document requires both a visual representation of the object and the underlying data. In this post, I am going to show you how to generate the IStorage and the image representing the embedded object by invoking the OLE Server associated with PDF files. To create the underlying data for a non-Office embedded object we need to look up the prog id of the application associated with the file format extension. To get this data we need to look under \HKCR\.XXX within the registry, where XXX is the file format extension (ex. PDF). Under this path you should see at least two sub keys: "(Default)" and "Content Type." The value specified for "(Default)" represents the prog id of the application associated with the file format. On my computer, the prog id associated with PDF files is "AcroExch.Document." 
&lt;/p&gt;

&lt;p&gt;Since we don't know the structure of the embedded object we shouldn't use the content type associated with the file format extension. Instead, we should use the generic content type for embedded objects, which is "application/vnd.openxmlformats-officedocument.oleObject." 
&lt;/p&gt;

&lt;p&gt;Our next step is to create the IStorage and an image representation for the embedded object. As mentioned in the Solution section above, we need to invoke the OLE Server associated with PDF files. Below is the &lt;b&gt;C++ code&lt;/b&gt; needed to accomplish this task:
&lt;/p&gt;
&lt;div&gt;
&lt;table style="background: rgb(253, 233, 217) 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="color: green; font-family: Courier New; font-size: 10pt;"&gt;//********** This snippet is C++ code *************//
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;HRESULT PackageOleObject(LPCTSTR inputFile, LPCTSTR 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;HRESULT hr = S_OK;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;IStoragePtr pStorage = NULL;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;IOleObjectPtr   pOle = NULL;   
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;IDataObjectPtr pdo = NULL;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;FORMATETC fetc;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;STGMEDIUM stgm;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;HENHMETAFILE hmeta;
&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="color: green; font-family: Courier New; font-size: 10pt;"&gt;// Create a compound storage document.
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;hr = StgCreateStorageEx (
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;outputFile,
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_TRANSACTED,
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;STGFMT_DOCFILE,
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;0,
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;NULL,
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;NULL,
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;IID_IStorage,
&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: blue;"&gt;reinterpret_cast&lt;/span&gt;&amp;lt;&lt;span style="color: blue;"&gt;void&lt;/span&gt;**&amp;gt;(&amp;amp;pStorage));
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;CheckHr(hr);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="color: green; font-family: Courier New; font-size: 10pt;"&gt;// Create OLE package from file.
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;hr =  OleCreateFromFile(CLSID_NULL,   inputFile,   ::IID_IOleObject,   
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 72pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;OLERENDER_NONE,   NULL,   NULL,   pStorage,   (&lt;span style="color: blue;"&gt;void&lt;/span&gt;**)&amp;amp;pOle);   
&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;hr = OleRun(pOle);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;CheckHr(hr);
&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;hr = pOle-&amp;gt;QueryInterface(IID_IDataObject, (&lt;span style="color: blue;"&gt;void&lt;/span&gt;**)&amp;amp;pdo);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;CheckHr(hr);
&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;fetc.cfFormat = CF_ENHMETAFILE;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;fetc.dwAspect = DVASPECT_CONTENT;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;fetc.lindex = -1;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;fetc.ptd = NULL;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;fetc.tymed = TYMED_ENHMF;
&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;stgm.hEnhMetaFile = NULL;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;stgm.tymed = TYMED_ENHMF;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;hr = pdo-&amp;gt;GetData(&amp;amp;fetc, &amp;amp;stgm);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;CheckHr(hr);
&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="color: green; font-family: Courier New; font-size: 10pt;"&gt;// Create image metafile for object.
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;CopyEnhMetaFile(stgm.hEnhMetaFile, emfFile);
&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;hr = pStorage-&amp;gt;Commit(STGC_DEFAULT );
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;CheckHr(hr);
&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;pOle-&amp;gt;Close(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;DeleteEnhMetaFile(stgm.hEnhMetaFile);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;DeleteEnhMetaFile(hmeta);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&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; hr;
&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 above C++ code snippet will create two output files that represent the IStorage and the image representation for our embedded object. 
&lt;/p&gt;

&lt;p&gt;We are now ready to accomplish the rest of the steps. Here is how you add the appropriate image data and embedded object data to a Word file:
&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;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(output, &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: rgb(43, 145, 175);"&gt;MainDocumentPart&lt;/span&gt; mainPart = myDoc.MainDocumentPart;
&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="color: green; font-family: Courier New; font-size: 10pt;"&gt;//Note that I created this emf file using my C++ solution
&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;ImagePart&lt;/span&gt; imagePart = mainPart.AddImagePart(&lt;span style="color: rgb(43, 145, 175);"&gt;ImagePartType&lt;/span&gt;.Emf);
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;imagePart.FeedData(&lt;span style="color: rgb(43, 145, 175);"&gt;File&lt;/span&gt;.Open(&lt;span style="color: rgb(163, 21, 21);"&gt;"output.emf"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;FileMode&lt;/span&gt;.Open));
&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;EmbeddedObjectPart&lt;/span&gt; embeddedObjectPart =
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;mainPart.AddEmbeddedObjectPart(&lt;span style="color: rgb(163, 21, 21);"&gt;@"application/vnd.openxmlformats-officedocument.oleObject"&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="color: green; font-family: Courier New; font-size: 10pt;"&gt;//Note that I created this bin file using my C++ solution
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;embeddedObjectPart.FeedData(&lt;span style="color: rgb(43, 145, 175);"&gt;File&lt;/span&gt;.Open(&lt;span style="color: rgb(163, 21, 21);"&gt;"input.pdf.bin"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;FileMode&lt;/span&gt;.Open));
&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&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;I should note that both the image and the embedded data were created using my C++ code that I showed you earlier in this post. The next step is to create a paragraph that represents our embedded object. Using the Document Reflector to help me out, I was able to create the following method: 
&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: 715px;"&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: rgb(43, 145, 175);"&gt;Paragraph&lt;/span&gt; CreateEmbeddedPDFParagraph(&lt;span style="color: blue;"&gt;string&lt;/span&gt; imageId, &lt;span style="color: blue;"&gt;string&lt;/span&gt; embedId, &lt;span style="color: blue;"&gt;string&lt;/span&gt; progId)
&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: rgb(43, 145, 175);"&gt;Paragraph&lt;/span&gt; p =
&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: blue;"&gt;new&lt;/span&gt;
								&lt;span style="color: rgb(43, 145, 175);"&gt;Paragraph&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 style="color: blue;"&gt;new&lt;/span&gt;
								&lt;span style="color: rgb(43, 145, 175);"&gt;Run&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;
								&lt;span style="color: rgb(43, 145, 175);"&gt;EmbeddedObject&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Shapetype&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Stroke&lt;/span&gt;() { JoinStyle = V.&lt;span style="color: rgb(43, 145, 175);"&gt;StrokeJoinStyleValues&lt;/span&gt;.Miter },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formulas&lt;/span&gt;(
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"if lineDrawn pixelLineWidth 0"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"sum @0 1 0"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"sum 0 0 @1"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"prod @2 1 2"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"prod @3 21600 pixelWidth"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"prod @3 21600 pixelHeight"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"sum @0 0 1"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"prod @6 1 2"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"prod @7 21600 pixelWidth"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"sum @8 21600 0"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"prod @7 21600 pixelHeight"&lt;/span&gt; },
&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Formula&lt;/span&gt;() { Equation = &lt;span style="color: rgb(163, 21, 21);"&gt;"sum @10 21600 0"&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Path&lt;/span&gt;() { AllowGradientShape = V.&lt;span style="color: rgb(43, 145, 175);"&gt;BooleanValues&lt;/span&gt;.T, ConnectionPointType = OVML.&lt;span style="color: rgb(43, 145, 175);"&gt;ConnectValues&lt;/span&gt;.Rectangle, AllowExtrusion = V.&lt;span style="color: rgb(43, 145, 175);"&gt;BooleanValues&lt;/span&gt;.F },
&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; OVML.&lt;span style="color: rgb(43, 145, 175);"&gt;Lock&lt;/span&gt;() { Extension = V.&lt;span style="color: rgb(43, 145, 175);"&gt;ExtensionHandlingBehaviorValues&lt;/span&gt;.Edit, AspectRatio = OVML.&lt;span style="color: rgb(43, 145, 175);"&gt;BooleanValues&lt;/span&gt;.T }
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 180pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;) { Id = &lt;span style="color: rgb(163, 21, 21);"&gt;"_x0000_t75"&lt;/span&gt;, CoordinateSize = &lt;span style="color: rgb(163, 21, 21);"&gt;"21600,21600"&lt;/span&gt;, Filled = V.&lt;span style="color: rgb(43, 145, 175);"&gt;BooleanValues&lt;/span&gt;.F, Stroked = V.&lt;span style="color: rgb(43, 145, 175);"&gt;BooleanValues&lt;/span&gt;.F, OptionalNumber = 75, PreferRelative = V.&lt;span style="color: rgb(43, 145, 175);"&gt;BooleanValues&lt;/span&gt;.T, EdgePath = &lt;span style="color: rgb(163, 21, 21);"&gt;"m@4@5l@4@11@9@11@9@5xe"&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;Shape&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; V.&lt;span style="color: rgb(43, 145, 175);"&gt;ImageData&lt;/span&gt;() { Title = &lt;span style="color: rgb(163, 21, 21);"&gt;""&lt;/span&gt;, RelationshipId = imageId }
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 180pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;) { Id = &lt;span style="color: rgb(163, 21, 21);"&gt;"_x0000_i1025"&lt;/span&gt;, Style = &lt;span style="color: rgb(163, 21, 21);"&gt;"width:459pt;height:594pt"&lt;/span&gt;, Ole = V.&lt;span style="color: rgb(43, 145, 175);"&gt;BooleanEntryWithBlankValues&lt;/span&gt;.Empty, Type = &lt;span style="color: rgb(163, 21, 21);"&gt;"#_x0000_t75"&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; OVML.&lt;span style="color: rgb(43, 145, 175);"&gt;OleObject&lt;/span&gt;() { Type = OVML.&lt;span style="color: rgb(43, 145, 175);"&gt;OLEValues&lt;/span&gt;.Embed, ProgId = progId, ShapeId = &lt;span style="color: rgb(163, 21, 21);"&gt;"_x0000_i1025"&lt;/span&gt;, DrawAspect = OVML.&lt;span style="color: rgb(43, 145, 175);"&gt;OLEDrawAspectValues&lt;/span&gt;.Content, ObjectId = &lt;span style="color: rgb(163, 21, 21);"&gt;"_1309181277"&lt;/span&gt;, Id = embedId }
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 144pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;) { DxaOriginal = (&lt;span style="color: rgb(43, 145, 175);"&gt;UInt32Value&lt;/span&gt;)9180U, DyaOriginal = (&lt;span style="color: rgb(43, 145, 175);"&gt;UInt32Value&lt;/span&gt;)11881U })
&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: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; p;
&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 last step of the solution is to swap out the content control for this newly created paragraph. 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: 715px;"&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: rgb(43, 145, 175);"&gt;Paragraph&lt;/span&gt; p = CreateEmbeddedPDFParagraph(
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;mainPart.GetIdOfPart(imagePart),
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;mainPart.GetIdOfPart(embeddedObjectPart),
&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(163, 21, 21);"&gt;"AcroExch.Document"&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: rgb(43, 145, 175);"&gt;SdtBlock&lt;/span&gt; sdt = mainPart.Document.Descendants&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;SdtBlock&lt;/span&gt;&amp;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;.Where(s =&amp;gt; s.GetFirstChild&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;SdtProperties&lt;/span&gt;&amp;gt;().GetFirstChild&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Alias&lt;/span&gt;&amp;gt;().Val.Value
&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;.Equals(&lt;span style="color: rgb(163, 21, 21);"&gt;"EmbedObject"&lt;/span&gt;)).First();
&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: rgb(43, 145, 175);"&gt;OpenXmlElement&lt;/span&gt; parent = sdt.Parent;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;parent.InsertAfter(p, sdt);
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;sdt.Remove();
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family: Courier New; font-size: 10pt;"&gt;mainPart.Document.Save();&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 should end up with a document that looks like the following: 
&lt;/p&gt;

&lt;p&gt;&lt;img src="http://zeyadrajabi.members.winisp.net/Embed3.png" alt="Embed3"&gt;&lt;/p&gt;

&lt;p&gt;Upon activating the embedded object I will see the following:
&lt;/p&gt;

&lt;p&gt;&lt;img src="http://zeyadrajabi.members.winisp.net/Embed4.png" alt="Embed4"&gt;&lt;/p&gt;

&lt;p&gt;Let me know if you guys are interested in more solutions around embedded objects.
&lt;/p&gt;

&lt;p&gt;Zeyad Rajabi&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Added video to blog post&lt;/em&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9843756" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Word/default.aspx">Word</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/WordprocessingML/default.aspx">WordprocessingML</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx">Zeyad's SDK Examples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category></item><item><title>Office 2010 Technical Preview</title><link>http://blogs.msdn.com/brian_jones/archive/2009/07/14/office-2010-technical-preview.aspx</link><pubDate>Wed, 15 Jul 2009 03:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9833688</guid><dc:creator>BrianJones</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9833688.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9833688</wfw:commentRss><description>&lt;P&gt;This week is really an exciting week for those of us who work on Office. We just released our first public offering of the Office 2010 Technical Preview. Check out the &lt;A href="http://www.microsoft.com/office/2010/" mce_href="http://www.microsoft.com/office/2010/"&gt;Office 2010&lt;/A&gt; website for articles, videos, and demos related to this Technical Preview. In today's post I am going to talk about, at a very high-level, some of the really cool developer-centric features we are introducing in Office 2010. In the coming months, in addition to Open XML SDK based solution blog posts, we will blog about Office 2010 based solutions/scenarios. &lt;/P&gt;
&lt;H2&gt;What's New for Developers in Office 2010? &lt;/H2&gt;
&lt;P&gt;Check out &lt;A href="http://blogs.msdn.com/johnrdurant/archive/2009/07/14/office-2010-developer-what-s-new.aspx" mce_href="http://blogs.msdn.com/johnrdurant/archive/2009/07/14/office-2010-developer-what-s-new.aspx"&gt;John Durant's blog post&lt;/A&gt;, where he does a great job highlighting some of the benefits Office 2010 provides for developers.&amp;nbsp; Here is a quick summary of some key additions/tools we have made as part of the Office 2010 wave: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Continual innovation of the &lt;A href="http://msdn.microsoft.com/en-us/library/bb448854(office.14).aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb448854(office.14).aspx"&gt;Open XML SDK&lt;/A&gt; – &lt;/STRONG&gt;&lt;SPAN style="COLOR: black"&gt;The Open XML SDK remains a big piece of our developer story for Office 2010. We've all seen a shift lately where solutions take more advantage of the cloud and services, and with that shift the need to consume, manipulate or create Office documents on the server becomes more important. The Open XML SDK is a vital tool in this new world for any developer and is a great complement to any service based solution. You've already seen this a bit in some of the services we provided in Office 2007…for example, while the Open XML SDK cannot accomplish recalculation, Excel Services can accomplish this scenario without any issues. Similarly, there may be operations that existing services aren't capable of, but the Open XML SDK is perfectly suited for (document assembly; data extraction; etc.). With this in mind, we are continuing to improve version 2 of the Open XML SDK, so that it fits in well with the new world of software + services. One big area of improvement is to make the Open XML SDK provide more robust validation, so that you will have an easier time ensuring that the server based solutions you write will create valid Office documents. Files you create with the Open XML SDK will work for both Office 2007 and Office 2010. In other words, you will now be able to use the SDK to create Office 2010 based solutions. Since the Open XML SDK will support Office 2010 based Open XML file formats, the final release of the Open XML Format SDK V2.0 will be available at the same time the final version of Office 2010 is available.&lt;SPAN style="TEXT-DECORATION: line-through"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Tighter relationship between Office and Visual Studio&lt;/STRONG&gt; – Visual Studio 2010 makes it even easier to create Office client or SharePoint based &lt;SPAN style="COLOR: black"&gt;solutions. Deployment for Office client solutions created with VS will be much simpler, with less runtime requirements. &lt;/SPAN&gt;In addition Visual Studio 2010 ships with more out of the box templates, which allows solutions to get off the ground quicker&lt;SPAN style="COLOR: #1f497d"&gt;.&lt;/SPAN&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Even easier to create rich solutions on top of Access 2010&lt;/STRONG&gt; – Check out the following &lt;A href="http://www.microsoft.com/office/2010/Access®%202010" mce_href="http://www.microsoft.com/office/2010/Access®%202010"&gt;video&lt;/A&gt; to see all the cool &lt;SPAN style="COLOR: black"&gt;improvements related to Access. This is a new model for development that we think you'll really enjoy.&lt;/SPAN&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;All Office 2010 applications now have Fluent UI&lt;/STRONG&gt; – The ribbon has now been added to more Office applications, like OneNote, Outlook (now is fully integrated throughout the UI), and Visio. Since the ribbon is based on XML, having all these applications incorporate the ribbon means a better extensibility story for developers. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Fluent UI has been improved&lt;/STRONG&gt; – In Office 2010 we have added the ability for programmatically activating tabs in the Fluent UI. For example, you can now have your custom tabs behave like built in contextual tabs, where tabs only show when specific events are fired. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Office 2010 has a new Backstage view&lt;/STRONG&gt; – One of the many UI improvements we have made in Office 2010 is the addition of a new extensible Backstage view to the products. This new UI not only improves the overall customer workflow and user experience, but also provides a rich extensible platform for developers. The Backstage view will allow you to add custom UI and elements much in the same way the ribbon provides extensibility. Check out &lt;A href="http://www.microsoft.com/office/2010/" mce_href="http://www.microsoft.com/office/2010/"&gt;Chris Bryant's brief intro&lt;/A&gt;, which showcases the Backstage in action. &lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Offload Excel calculations to High Performance Computing grids&lt;/STRONG&gt; – In Excel 2007 we added multi-threaded recalculation (MTR) to Excel, including the ability for developers to create user defined functions (UDFs) that could &lt;A href="http://blogs.msdn.com/excel/archive/2006/01/03/508985.aspx" mce_href="http://blogs.msdn.com/excel/archive/2006/01/03/508985.aspx"&gt;participate in MTR&lt;/A&gt;.&amp;nbsp; With Excel 2010, we've gone a step further to allow massive parallelization by offloading UDFs from the local machine to a high performance computing grid, with very minimal changes to existing XLL UDFs. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Again, in the next few weeks we will be posting more Office 2010 centric posts, so stay tuned. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="COLOR: black"&gt;- Brian and Zeyad &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Updated post to correct a broken link...&lt;/EM&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9833688" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Office+2010/default.aspx">Office 2010</category></item><item><title>Embedding an Open XML File in another Open XML File</title><link>http://blogs.msdn.com/brian_jones/archive/2009/06/30/embedding-an-open-xml-file-in-another-open-xml-file.aspx</link><pubDate>Wed, 01 Jul 2009 01:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9810106</guid><dc:creator>BrianJones</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/brian_jones/comments/9810106.aspx</comments><wfw:commentRss>http://blogs.msdn.com/brian_jones/commentrss.aspx?PostID=9810106</wfw:commentRss><description>&lt;P&gt;A couple of weeks ago I gave a presentation on the Open XML SDK to a few customers, where I was asked questions on how to embed files within Open XML documents. I thought it would be a good opportunity to devote a couple of posts around this topic. In today's post I am going to show you how to embed an Open XML file in another Open XML file. Specifically, I am going to show you how to embed an Excel spreadsheet (.xlsx) into a Word document (.docx). Next post will cover how to embed other file types in Open XML files. &lt;/P&gt;
&lt;P&gt;My post will talk about using &lt;A href="http://go.microsoft.com/fwlink/?LinkId=127912" mce_href="http://go.microsoft.com/fwlink/?LinkId=127912"&gt;version 2 of the SDK&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;If you just want to jump straight into the code, feel free to download this solution &lt;A href="http://zeyadrajabi.members.winisp.net/sourcecode/EmbedExcelFileIntoWord.zip" mce_href="http://zeyadrajabi.members.winisp.net/sourcecode/EmbedExcelFileIntoWord.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/xunFeqCW2GA&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/xunFeqCW2GA&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;Solution &lt;/H2&gt;
&lt;P&gt;To embed an Excel spreadsheet into a Word document we can take the following actions: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a template in Word that contains a content control that will be used to demarcate the region where the embedded object will be inserted &lt;/LI&gt;
&lt;LI&gt;Open up the Word document via the Open XML SDK and access its main document part &lt;/LI&gt;
&lt;LI&gt;Add an image part to the document (this image will be a placeholder image of the embedded object file) &lt;/LI&gt;
&lt;LI&gt;Add an embedded package part to the document &lt;/LI&gt;
&lt;LI&gt;Create a paragraph that contains the embedded object &lt;/LI&gt;
&lt;LI&gt;Locate the content control that will contain the embedded object &lt;/LI&gt;
&lt;LI&gt;Swap out the content control for the newly created paragraph &lt;/LI&gt;
&lt;LI&gt;Save changes made to the Word document &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Note that the steps outlined above are just one method to accomplish this scenario. &lt;/P&gt;
&lt;P&gt;For the sake of this example, let's say I am starting with the following Word document: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan1.png" mce_src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan1.png"&gt; &lt;/P&gt;
&lt;P&gt;This document contains a content control, named "EmbedObject," which will contain my embedded object. In addition, let's say I have the following Excel spreadsheet I wish to embed: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan2.png" mce_src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan2.png"&gt; &lt;/P&gt;
&lt;H2&gt;Embedded Objects in Open XML &lt;/H2&gt;
&lt;P&gt;Before we get into the code, I wanted to talk more about embedded objects. Office has three ways of storing embedded objects: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Those where Office persists the &lt;A href="http://msdn.microsoft.com/en-us/library/aa380015.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa380015.aspx"&gt;IStorage&lt;/A&gt; as given to Office during OLE operations &lt;/LI&gt;
&lt;LI&gt;Those where Office persists the IStorage as given during OLE operations, but gives the embedded object a friendly extension and filename. This method assumes that the embedded object is a native file format of the application in question &lt;/LI&gt;
&lt;LI&gt;Those where Office interprets the IStorage given during OLE operations as simply a wrapper for a package and only stores the package. This method assumes that the package conforms to Open Packaging Conventions &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The major difference between #0 vs. #1 and #2 is in how objects are embedded within a file. Types #1 and #2 allows developers working with Open XML files to more easily extract and insert embedded objects because there is no need to talk to an OLE server. Instead, developers can simply read/write embedded objects as if they were reading from or writing to files on disk. Office differentiates between these three types by looking for a specific registry key under HKCR\CLSID\{Apps_OLE_Storage_CLSID}, where Apps_OLE_Storage_CLSID is the CLSID of the OLE storage server. The Office applications look for a subkey named IPersistStorageType and determines the type of the embedded object in the following manner: &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Office assumes the embedded object is type #0 if no subkey is specified or if the value of the subkey is 0 &lt;/LI&gt;
&lt;LI&gt;Office assumes the embedded object is type #1 if the subkey has a value of 1 &lt;/LI&gt;
&lt;LI&gt;Office assumes the embedded object is type #2 if the subkey has a value of 2 &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The cool thing is that other applications can take advantage of this reg key. For example, if an application writes out a value of 1 for this subkey for a particular file format then the Office applications will embed files of that type natively in the Open XML file formats. &lt;/P&gt;
&lt;P&gt;One more thing to note is that all embedded object types require a prog id, which you can find from the registry, as well as an image representation of the object. &lt;/P&gt;
&lt;H2&gt;The Code &lt;/H2&gt;
&lt;P&gt;As mentioned above, when an object is embedded in a document, both a visual representation of the object and the underlying data is stored. The visual representation is simply an image of what you would see if you were to activate the object. For the sake of this solution, my visual representation of the document will be a placeholder image that indicates to users how to refresh the embedded object and will look like the following image: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan3.png" mce_src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan3.png"&gt; &lt;/P&gt;
&lt;P&gt;Looking at the steps outlined above in the &lt;A href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=4689&amp;amp;postid=9810106#_Solution" mce_href="http://blogs.msdn.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=Posts&amp;amp;sectionid=4689&amp;amp;postid=9810106#_Solution"&gt;Solution&lt;/A&gt; section, here is the code snippet to accomplish steps two through four: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 650px"&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;WordprocessingDocument&lt;/SPAN&gt; myDoc = &lt;SPAN style="COLOR: #2b91af"&gt;WordprocessingDocument&lt;/SPAN&gt;.Open(output, &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;MainDocumentPart&lt;/SPAN&gt; mainPart = myDoc.MainDocumentPart; &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;ImagePart&lt;/SPAN&gt; imagePart = mainPart.AddImagePart(&lt;SPAN style="COLOR: #2b91af"&gt;ImagePartType&lt;/SPAN&gt;.Png); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;imagePart.FeedData(&lt;SPAN style="COLOR: #2b91af"&gt;File&lt;/SPAN&gt;.Open(&lt;SPAN style="COLOR: #a31515"&gt;"placeholder.png"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #2b91af"&gt;FileMode&lt;/SPAN&gt;.Open)); &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;EmbeddedPackagePart&lt;/SPAN&gt; embeddedObjectPart = &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 72pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;mainPart.AddEmbeddedPackagePart(&lt;SPAN style="COLOR: #a31515"&gt;@"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&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;embeddedObjectPart.FeedData(&lt;SPAN style="COLOR: #2b91af"&gt;File&lt;/SPAN&gt;.Open(&lt;SPAN style="COLOR: #a31515"&gt;"embed.xlsx"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #2b91af"&gt;FileMode&lt;/SPAN&gt;.Open)); &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 placeholder.png refers to the placeholder image I showed you above and the embed.xlsx file is the spreadsheet that will be embedded. The string "&lt;SPAN style="FONT-FAMILY: Courier New; COLOR: #a31515; FONT-SIZE: 10pt"&gt;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&lt;/SPAN&gt;" represents the content type of an Excel spreadsheet with an extension .xlsx. You can find the content type of a particular file by going to HKCR\.XXX, where XXX is the extension of the file format, and looking for a sub key named "Content Type." &lt;/P&gt;
&lt;P&gt;The next step is to create a paragraph that represents our embedded object. Like my other post on &lt;A href="http://blogs.msdn.com/brian_jones/archive/2009/06/04/importing-smartart-from-powerpoint-to-word.aspx" mce_href="http://blogs.msdn.com/brian_jones/archive/2009/06/04/importing-smartart-from-powerpoint-to-word.aspx"&gt;importing SmartArt from PowerPoint to Word&lt;/A&gt;, I am going to take advantage of the Document Reflector tool that ships free with the SDK. Using this tool's output as a starting point, I am able to generate the necessary paragraph with the following code snippet: &lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: #dbe5f1" border=0&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 820px"&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; &lt;SPAN style="COLOR: #2b91af"&gt;Paragraph&lt;/SPAN&gt; CreateEmbeddedObjectParagraph(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; imageId, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; embedId) &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;Paragraph&lt;/SPAN&gt; p = &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: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Paragraph&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 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 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; &lt;SPAN style="COLOR: #2b91af"&gt;EmbeddedObject&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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Shapetype&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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Stroke&lt;/SPAN&gt;() { JoinStyle = V.&lt;SPAN style="COLOR: #2b91af"&gt;StrokeJoinStyleValues&lt;/SPAN&gt;.Miter }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formulas&lt;/SPAN&gt;( &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"if lineDrawn pixelLineWidth 0"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"sum @0 1 0"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"sum 0 0 @1"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"prod @2 1 2"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"prod @3 21600 pixelWidth"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"prod @3 21600 pixelHeight"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"sum @0 0 1"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"prod @6 1 2"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"prod @7 21600 pixelWidth"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"sum @8 21600 0"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"prod @7 21600 pixelHeight"&lt;/SPAN&gt; }, &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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Formula&lt;/SPAN&gt;() { Equation = &lt;SPAN style="COLOR: #a31515"&gt;"sum @10 21600 0"&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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Path&lt;/SPAN&gt;() { AllowGradientShape = V.&lt;SPAN style="COLOR: #2b91af"&gt;BooleanValues&lt;/SPAN&gt;.T, ConnectionPointType = OVML.&lt;SPAN style="COLOR: #2b91af"&gt;ConnectValues&lt;/SPAN&gt;.Rectangle, AllowExtrusion = V.&lt;SPAN style="COLOR: #2b91af"&gt;BooleanValues&lt;/SPAN&gt;.F }, &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; OVML.&lt;SPAN style="COLOR: #2b91af"&gt;Lock&lt;/SPAN&gt;() { Extension = V.&lt;SPAN style="COLOR: #2b91af"&gt;ExtensionHandlingBehaviorValues&lt;/SPAN&gt;.Edit, AspectRatio = OVML.&lt;SPAN style="COLOR: #2b91af"&gt;BooleanValues&lt;/SPAN&gt;.T } &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;) { Id = &lt;SPAN style="COLOR: #a31515"&gt;"_x0000_t75"&lt;/SPAN&gt;, CoordinateSize = &lt;SPAN style="COLOR: #a31515"&gt;"21600,21600"&lt;/SPAN&gt;, Filled = V.&lt;SPAN style="COLOR: #2b91af"&gt;BooleanValues&lt;/SPAN&gt;.F, Stroked = V.&lt;SPAN style="COLOR: #2b91af"&gt;BooleanValues&lt;/SPAN&gt;.F, OptionalNumber = 75, PreferRelative = V.&lt;SPAN style="COLOR: #2b91af"&gt;BooleanValues&lt;/SPAN&gt;.T, EdgePath = &lt;SPAN style="COLOR: #a31515"&gt;"m@4@5l@4@11@9@11@9@5xe"&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; V.&lt;SPAN style="COLOR: #2b91af"&gt;Shape&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; V.&lt;SPAN style="COLOR: #2b91af"&gt;ImageData&lt;/SPAN&gt;() { Title = &lt;SPAN style="COLOR: #a31515"&gt;""&lt;/SPAN&gt;, RelationshipId = imageId } &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 180pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;) { Id = &lt;SPAN style="COLOR: #a31515"&gt;"_x0000_i1025"&lt;/SPAN&gt;, Style = &lt;SPAN style="COLOR: #a31515"&gt;"width:500pt;height:400pt"&lt;/SPAN&gt;, Ole = V.&lt;SPAN style="COLOR: #2b91af"&gt;BooleanEntryWithBlankValues&lt;/SPAN&gt;.Empty, Type = &lt;SPAN style="COLOR: #a31515"&gt;"#_x0000_t75"&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; OVML.&lt;SPAN style="COLOR: #2b91af"&gt;OleObject&lt;/SPAN&gt;() { Type = OVML.&lt;SPAN style="COLOR: #2b91af"&gt;OLEValues&lt;/SPAN&gt;.Embed, ProgId = &lt;SPAN style="COLOR: #a31515"&gt;"Excel.Sheet.12"&lt;/SPAN&gt;, ShapeId = &lt;SPAN style="COLOR: #a31515"&gt;"_x0000_i1025"&lt;/SPAN&gt;, DrawAspect = OVML.&lt;SPAN style="COLOR: #2b91af"&gt;OLEDrawAspectValues&lt;/SPAN&gt;.Content, ObjectId = &lt;SPAN style="COLOR: #a31515"&gt;"_1307530183"&lt;/SPAN&gt;, Id = embedId } &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 108pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;) { DxaOriginal = (&lt;SPAN style="COLOR: #2b91af"&gt;UInt32Value&lt;/SPAN&gt;)10957U, DyaOriginal = (&lt;SPAN style="COLOR: #2b91af"&gt;UInt32Value&lt;/SPAN&gt;)8455U }) &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: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; p; &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 last step of the solution is to swap out the content control for this newly created paragraph. This code is very similar to a lot of my previous posts where I used content controls as semantic structures. Here is the 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: 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;Paragraph&lt;/SPAN&gt; p = CreateEmbeddedObjectParagraph(mainPart.GetIdOfPart(imagePart), &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;mainPart.GetIdOfPart(embeddedObjectPart)); &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;SdtBlock&lt;/SPAN&gt; sdt = mainPart.Document.Descendants&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;SdtBlock&lt;/SPAN&gt;&amp;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;.Where(s =&amp;gt; s.GetFirstChild&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;SdtProperties&lt;/SPAN&gt;&amp;gt;().GetFirstChild&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Alias&lt;/SPAN&gt;&amp;gt;().Val.Value &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 36pt"&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;.Equals(&lt;SPAN style="COLOR: #a31515"&gt;"EmbedObject"&lt;/SPAN&gt;)).First(); &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;OpenXmlElement&lt;/SPAN&gt; parent = sdt.Parent; &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;parent.InsertAfter(p, sdt); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;sdt.Remove(); &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-FAMILY: Courier New; FONT-SIZE: 10pt"&gt;mainPart.Document.Save();&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 should end up with a document that looks like the following: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan4.png" mce_src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan4.png"&gt; &lt;/P&gt;
&lt;P&gt;Upon activating the embedded object I will see the following: &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="" src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan5.png" mce_src="http://zeyadrajabi.members.winisp.net/063009_2157_Embeddingan5.png"&gt; &lt;/P&gt;
&lt;P&gt;Pretty easy stuff! Next time I will show you how to embed other file formats, like PDF. &lt;/P&gt;
&lt;P&gt;Zeyad Rajabi &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9810106" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/brian_jones/archive/tags/OpenXML+Developers/default.aspx">OpenXML Developers</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/WordprocessingML/default.aspx">WordprocessingML</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Zeyad_2700_s+SDK+Examples/default.aspx">Zeyad's SDK Examples</category><category domain="http://blogs.msdn.com/brian_jones/archive/tags/Open+XML+SDK/default.aspx">Open XML SDK</category></item></channel></rss>