<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Coding The Document</title>
	<atom:link href="http://codingthedocument.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codingthedocument.wordpress.com</link>
	<description>Helping you leverage document generation standards</description>
	<lastBuildDate>Thu, 31 Mar 2011 19:56:16 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='codingthedocument.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Coding The Document</title>
		<link>http://codingthedocument.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codingthedocument.wordpress.com/osd.xml" title="Coding The Document" />
	<atom:link rel='hub' href='http://codingthedocument.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Alternate OOXML Document Generation Approach</title>
		<link>http://codingthedocument.wordpress.com/2011/03/31/alternate-ooxml-document-generation-approach/</link>
		<comments>http://codingthedocument.wordpress.com/2011/03/31/alternate-ooxml-document-generation-approach/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 19:56:13 +0000</pubDate>
		<dc:creator>Tim Murphy</dc:creator>
				<category><![CDATA[Office Open XML]]></category>
		<category><![CDATA[Document Generation]]></category>
		<category><![CDATA[OOXML]]></category>

		<guid isPermaLink="false">https://codingthedocument.wordpress.com/2011/03/31/alternate-ooxml-document-generation-approach/</guid>
		<description><![CDATA[Eric White has put out a document generation example which uses XPath and Word Content Controls.&#160; I applaud Eric for the amount of work he has done with his exploration of different ways to perform template base generation.&#160; This is a subject that is challenging and we need as many ideas as we can get.&#160; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=58&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://ericwhite.com/blog/" target="_blank">Eric White</a> has put out a document generation <a href="http://ericwhite.com/blog/2011/03/29/release-of-v2-of-doc-gen-system-xpath-in-content-controls/" target="_blank">example</a> which uses XPath and Word Content Controls.&#160; I applaud Eric for the amount of work he has done with his exploration of different ways to perform template base generation.&#160; This is a subject that is challenging and we need as many ideas as we can get.&#160; There are a couple of areas that I see room for improvement in this XPath design that I would like to bring up.&#160; </p>
<p>The first is that Eric has chosen to put his document generation in the document itself.&#160; I see this as a maintenance and reusability issue.&#160; Architecturally I would prefer to have my code external to the document so that I can write and maintain it centrally in a generic fashion and tie it to a rules engine.</p>
<p>Another place I see that this approach falls down is that it is good for simple text replacement, but it doesn’t handle formatting, replacing images or working with charts.&#160; This doesn’t mean that it can’t handle them, but I think it would lose the simplicity which looks to be it’s appeal.</p>
<p>Lastly, Content Controls are currently a Word only feature.&#160; It would be great if we could come up with a mark-up technique that was universal to all Office document types.&#160; Hey, we can dream, right?</p>
<p>Personally, I prefer a more meta data driven approach based on my experience with solutions which had output that was more marketing material quality.&#160; That being said, but approach is an interesting idea to add to the design arsenal.&#160; Thanks for the thoughts Eric.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c775260e-cd96-4dd8-a8f3-52ebd64445de" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/OOXML" rel="tag">OOXML</a>,<a href="http://del.icio.us/popular/Office+Open+XML" rel="tag">Office Open XML</a>,<a href="http://del.icio.us/popular/Eric+White" rel="tag">Eric White</a>,<a href="http://del.icio.us/popular/Document+Generation" rel="tag">Document Generation</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=58&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2011/03/31/alternate-ooxml-document-generation-approach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1436727bb92bde90faae268f7330bcef?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tmurphy</media:title>
		</media:content>
	</item>
		<item>
		<title>Update Since Microsoft/PSC Office Open XML Case Study</title>
		<link>http://codingthedocument.wordpress.com/2010/12/16/update-since-microsoftpsc-office-open-xml-case-study/</link>
		<comments>http://codingthedocument.wordpress.com/2010/12/16/update-since-microsoftpsc-office-open-xml-case-study/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 04:27:38 +0000</pubDate>
		<dc:creator>Tim Murphy</dc:creator>
				<category><![CDATA[Office Open XML]]></category>
		<category><![CDATA[Case Study]]></category>
		<category><![CDATA[OOXML]]></category>
		<category><![CDATA[PSC Group]]></category>

		<guid isPermaLink="false">https://codingthedocument.wordpress.com/2010/12/16/update-since-microsoftpsc-office-open-xml-case-study/</guid>
		<description><![CDATA[In 2009 Microsoft released a case study about a project that we had done using the OOXML SDK 1.0 for Research Directors Inc.&#160; Since that time Microsoft has released version 2.0 of the SDK and PSC has done significant development with it.&#160; Below are some of the mile stones we have reached since the original [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=57&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In 2009 Microsoft released a <a href="http://www.microsoft.com/casestudies/Case_Study_Detail.aspx?CaseStudyID=4000005717" target="_blank">case study</a> about a project that we had done using the OOXML SDK 1.0 for Research Directors Inc.&#160; Since that time Microsoft has released version 2.0 of the SDK and PSC has done significant development with it.&#160; Below are some of the mile stones we have reached since the original case study.</p>
<p>At the time of the original case study two report types had been automated to output as PowerPoint presentations.&#160; Now that the all the main products have been delivered we have added three reports with Word document outputs and five more reports with PowerPoint outputs. </p>
<p>One improvement we made over the original application was to create a PowerPoint Add-In which allows the users to tag a slide.&#160; These tags along with the strongly typed SDK 2.0 allows for the code to use LINQ to easily search for slides in the template files.&#160; This allows for a more flexible architecture base on assembling a presentation from copied slide extracted from the template.</p>
<p>The new library we created also enabled us to create two new Word based reports in two weeks.&#160; The library we created abstracts the generation of the documents from the business logic and the data retrieval.&#160; The key to this is the mark up.&#160; Content Controls are a good method for identifying sections of a template to be modified or replaced.&#160; Join this with the concept of all data being generically either scalar or two dimensional and the code becomes more generic.</p>
<p>In the end we found the OOXML SDK 2.0 to be a great tool for accelerating document generation development and creating happy clients.&#160; </p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:76462b2b-b334-465b-b472-abb380599c03" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/PSC+Group" rel="tag">PSC Group</a>,<a href="http://del.icio.us/popular/OOXML" rel="tag">OOXML</a>,<a href="http://del.icio.us/popular/Case+Study" rel="tag">Case Study</a>,<a href="http://del.icio.us/popular/Office+Open+XML" rel="tag">Office Open XML</a>,<a href="http://del.icio.us/popular/Word" rel="tag">Word</a>,<a href="http://del.icio.us/popular/PowerPoint" rel="tag">PowerPoint</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=57&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/12/16/update-since-microsoftpsc-office-open-xml-case-study/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1436727bb92bde90faae268f7330bcef?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tmurphy</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating New Presentations from Slide Masters Using OpenXML (Revisited)</title>
		<link>http://codingthedocument.wordpress.com/2010/05/04/creating-new-presentations-from-slide-masters-using-openxml-revisited/</link>
		<comments>http://codingthedocument.wordpress.com/2010/05/04/creating-new-presentations-from-slide-masters-using-openxml-revisited/#comments</comments>
		<pubDate>Tue, 04 May 2010 16:00:19 +0000</pubDate>
		<dc:creator>Andrew Schwantes</dc:creator>
				<category><![CDATA[Office Open XML]]></category>
		<category><![CDATA[PowerPoint]]></category>

		<guid isPermaLink="false">https://codingthedocument.wordpress.com/2010/05/04/creating-new-presentations-from-slide-masters-using-openxml-revisited/</guid>
		<description><![CDATA[Here’s an update to a prior post, Creating New Presentations from Slide Masters Using OpenXML, about creating new presentation slides from the slide master.  A reader commented about an error with layouts that had images in them and it came to my attention that my code completely ignored the images.  Here’s an update: private static [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=51&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here’s an update to a prior post, <a href="http://codingthedocument.wordpress.com/2010/03/24/creating-new-presentations-using-the-slide-master/">Creating New Presentations from Slide Masters Using OpenXML</a>, about creating new presentation slides from the slide master.  A reader commented about an error with layouts that had images in them and it came to my attention that my code completely ignored the images.  Here’s an update:</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> InsertSlide(PresentationPart pPart, <span style="color:#0000ff;">string</span> layoutName, UInt32 slideId)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">        {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            Slide slide = <span style="color:#0000ff;">new</span> Slide(<span style="color:#0000ff;">new</span> CommonSlideData(<span style="color:#0000ff;">new</span> ShapeTree()));</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">            SlidePart sPart = pPart.AddNewPart&lt;SlidePart&gt;();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            slide.Save(sPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">            SlideMasterPart smPart = pPart.SlideMasterParts.First();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            SlideLayoutPart slPart = smPart.SlideLayoutParts.Single(kaark =&gt; kaark.SlideLayout.CommonSlideData.Name == layoutName);</pre>
<p><!--CRLF--></p>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            <span style="color:#008000;">//Add the layout part to the new slide from the slide master</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">            sPart.AddPart&lt;SlideLayoutPart&gt;(slPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            sPart.Slide.CommonSlideData = (CommonSlideData)smPart.SlideLayoutParts.Single(kaark =&gt; kaark.SlideLayout.CommonSlideData.Name == layoutName).SlideLayout.CommonSlideData.Clone();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            <span style="color:#0000ff;">using</span> (Stream stream = slPart.GetStream())</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">            {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">                sPart.SlideLayoutPart.FeedData(stream);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">            }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">            <span style="color:#008000;">//UPDATED: Copy the images from the slide master layout to the new slide</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            <span style="color:#0000ff;">foreach</span> (ImagePart iPart <span style="color:#0000ff;">in</span> slPart.ImageParts)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">            {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">                ImagePart newImagePart = sPart.AddImagePart(iPart.ContentType, slPart.GetIdOfPart(iPart));</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">                newImagePart.FeedData(iPart.GetStream());</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            SlideId newSlideId = pPart.Presentation.SlideIdList.AppendChild&lt;SlideId&gt;(<span style="color:#0000ff;">new</span> SlideId());</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">            newSlideId.Id = slideId;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">            newSlideId.RelationshipId = pPart.GetIdOfPart(sPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">        }</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>After feeding the slide layout part data into the new slide’s layout part, the code then adds the new image parts to the slide from the slide master layout.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=51&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/05/04/creating-new-presentations-from-slide-masters-using-openxml-revisited/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57649c22ae11bdbf2eaf910c5116a41a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kaark</media:title>
		</media:content>
	</item>
		<item>
		<title>Experience OOXML  In Person</title>
		<link>http://codingthedocument.wordpress.com/2010/04/21/experience-ooxml-in-person/</link>
		<comments>http://codingthedocument.wordpress.com/2010/04/21/experience-ooxml-in-person/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 03:22:07 +0000</pubDate>
		<dc:creator>Tim Murphy</dc:creator>
				<category><![CDATA[Chicago Code Camp]]></category>
		<category><![CDATA[Office Open XML]]></category>

		<guid isPermaLink="false">http://codingthedocument.wordpress.com/2010/04/21/experience-ooxml-in-person/</guid>
		<description><![CDATA[The Chicago Code Camp is coming up on May 1st.&#160; I will be presenting on the essentials of document generation with OOXML.&#160; The code I will be showing will leverage the 2.0 SDK.&#160; Join us and come with your questions about Open XML. http://www.chicagocodecamp.com del.icio.us Tags: Chicago Code Camp,OOXML SDK 2.0,Office Open XML,PSC Group<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=48&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The Chicago Code Camp is coming up on May 1st.&#160; I will be presenting on the essentials of document generation with OOXML.&#160; The code I will be showing will leverage the 2.0 SDK.&#160; Join us and come with your questions about Open XML.</p>
<p><a href="http://www.chicagocodecamp.com">http://www.chicagocodecamp.com</a></p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:d2ddbd36-1908-4320-a1a2-d8190b88ff53" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/Chicago+Code+Camp" rel="tag">Chicago Code Camp</a>,<a href="http://del.icio.us/popular/OOXML+SDK+2.0" rel="tag">OOXML SDK 2.0</a>,<a href="http://del.icio.us/popular/Office+Open+XML" rel="tag">Office Open XML</a>,<a href="http://del.icio.us/popular/PSC+Group" rel="tag">PSC Group</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=48&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/04/21/experience-ooxml-in-person/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1436727bb92bde90faae268f7330bcef?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tmurphy</media:title>
		</media:content>
	</item>
		<item>
		<title>Dealing With Table Borders In OOXML</title>
		<link>http://codingthedocument.wordpress.com/2010/04/05/dealing-with-table-borders-in-ooxml/</link>
		<comments>http://codingthedocument.wordpress.com/2010/04/05/dealing-with-table-borders-in-ooxml/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 21:35:09 +0000</pubDate>
		<dc:creator>Tim Murphy</dc:creator>
				<category><![CDATA[Office Open XML]]></category>
		<category><![CDATA[Office 2007]]></category>
		<category><![CDATA[OOXML]]></category>

		<guid isPermaLink="false">http://codingthedocument.wordpress.com/2010/04/05/dealing-with-table-borders-in-ooxml/</guid>
		<description><![CDATA[Formatting tables in a document programmatically can be a very complex task.  This is the major reason which we start our document generation projects with templates instead of building components in a document by hand. Borders are on aspect of a table that you may want to fomat.  Borders are used to make certain content [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=45&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Formatting tables in a document programmatically can be a very complex task.  This is the major reason which we start our document generation projects with templates instead of building components in a document by hand.</p>
<p>Borders are on aspect of a table that you may want to fomat.  Borders are used to make certain content in a table stand out.  If you need to conditionally set and remove borders there is something that you need to be aware of.  Even in OOXML you have the concepts of styles, inheriting styles and overriding styles.</p>
<p>When Word defines a table it will reference a global style such as “TableGrid”.  This style will include the borders for the table.  Specifically the InsideHorizontalBorder and InsideVerticalBorder define the borders for the cells.  These can be overridden by the TableCellBorders collection of a particular cell.  Adding a double right border on a cell is as easy as the couple of lines of code below.</p>
<div id="codeSnippetWrapper" style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">wordprocessing.TableCellBorders borders = <span style="color:#0000ff;">new</span> wordprocessing.TableCellBorders();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;">borders.RightBorder = <span style="color:#0000ff;">new</span> RightBorder(){Val = BorderValues.Double, Color = <span style="color:#006080;">"000000"</span>, ThemeColor = ThemeColorValues.Text1, Size = (UInt32Value)4U, Space = (UInt32Value)0U };</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;">cell.TableCellProperties.Append(borders);</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>If I want to revert back to the table’s style for cell borders I simply need to remove all children from the TableCellBorders collection.  It is like removing a class identifier from a TD tag in HTML.  The style in the parent object takes back over.</p>
<p>With the knowledge of how the borders work you can take the concept and apply it to other effects of styles.</p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:28a56304-43d9-4b38-a984-4c39f4e1f313" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">del.icio.us Tags: <a rel="tag" href="http://del.icio.us/popular/OOXML">OOXML</a>,<a rel="tag" href="http://del.icio.us/popular/Office+Open+XML">Office Open XML</a>,<a rel="tag" href="http://del.icio.us/popular/Microsoft+Office+2007">Microsoft Office 2007</a>,<a rel="tag" href="http://del.icio.us/popular/Microsoft+Word+2007">Microsoft Word 2007</a>,<a rel="tag" href="http://del.icio.us/popular/table">table</a>,<a rel="tag" href="http://del.icio.us/popular/style">style</a>,<a rel="tag" href="http://del.icio.us/popular/border">border</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=45&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/04/05/dealing-with-table-borders-in-ooxml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1436727bb92bde90faae268f7330bcef?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tmurphy</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating New Presentations from Slide Masters Using OpenXML</title>
		<link>http://codingthedocument.wordpress.com/2010/03/24/creating-new-presentations-using-the-slide-master/</link>
		<comments>http://codingthedocument.wordpress.com/2010/03/24/creating-new-presentations-using-the-slide-master/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 15:22:00 +0000</pubDate>
		<dc:creator>Andrew Schwantes</dc:creator>
				<category><![CDATA[Office Open XML]]></category>
		<category><![CDATA[PowerPoint]]></category>

		<guid isPermaLink="false">http://codingthedocument.wordpress.com/2010/03/24/creating-new-presentations-using-the-slide-master/</guid>
		<description><![CDATA[The slide master in Powerpoint provides a powerful way for end-users to easily control the appearance and layouts of a presentation.  A slide master contains a set of layouts that are subsequently used by the slides in the presentation. A common approach to constructing  a new presentation is to have a template with slides that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=41&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The slide master in Powerpoint provides a powerful way for end-users to easily control the appearance and layouts of a presentation.  A slide master contains a set of layouts that are subsequently used by the slides in the presentation.</p>
<p>A common approach to constructing  a new presentation is to have a template with slides that are then copied/merged into the new presentation.  The approach I will be demonstrating creates slides in the new presentation based off the slide master layouts in the template.  This approach still requires a template, but does not require slides to already exist. </p>
<p><strong>The Template</strong></p>
<p>The template I used contained a few layouts in the slide master, each arranged with some placeholder objects.  A great benefit of layouts in the slide master is that they can be renamed through the UI.  The layout name is what will be used in the code to construct the slide deck in the new presentation.</p>
<p><strong>The Code</strong></p>
<p>Now the fun part.  The InsertSlide method takes a PresentationPart, layout name from the slide master, and ID for the new slide.  It creates the new Slide and adds the associated parts to the PresentationPart, copying all the required layout and common slide data from the slide master layout.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum1" style="color:#606060;">   1:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> InsertSlide(PresentationPart pPart, <span style="color:#0000ff;">string</span> layoutName, UInt32 slideId)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum2" style="color:#606060;">   2:</span>         {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum3" style="color:#606060;">   3:</span>             Slide slide = <span style="color:#0000ff;">new</span> Slide(<span style="color:#0000ff;">new</span> CommonSlideData(<span style="color:#0000ff;">new</span> ShapeTree()));</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum4" style="color:#606060;">   4:</span> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum5" style="color:#606060;">   5:</span>             SlidePart sPart = pPart.AddNewPart&lt;SlidePart&gt;();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum6" style="color:#606060;">   6:</span>             slide.Save(sPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum7" style="color:#606060;">   7:</span> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum8" style="color:#606060;">   8:</span>             SlideMasterPart smPart = pPart.SlideMasterParts.First();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum9" style="color:#606060;">   9:</span>             SlideLayoutPart slPart = smPart.SlideLayoutParts.Single(kaark =&gt; kaark.SlideLayout.CommonSlideData.Name == layoutName);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum10" style="color:#606060;">  10:</span>             sPart.AddPart&lt;SlideLayoutPart&gt;(slPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum11" style="color:#606060;">  11:</span>             sPart.Slide.CommonSlideData = (CommonSlideData)smPart.SlideLayoutParts.Single(kaark =&gt; kaark.SlideLayout.CommonSlideData.Name == layoutName).SlideLayout.CommonSlideData.Clone();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum12" style="color:#606060;">  12:</span>             <span style="color:#0000ff;">using</span> (Stream stream = slPart.GetStream())</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum13" style="color:#606060;">  13:</span>             {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum14" style="color:#606060;">  14:</span>                 sPart.SlideLayoutPart.FeedData(stream);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum15" style="color:#606060;">  15:</span>             }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum16" style="color:#606060;">  16:</span> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum17" style="color:#606060;">  17:</span>             SlideId newSlideId = pPart.Presentation.SlideIdList.AppendChild&lt;SlideId&gt;(<span style="color:#0000ff;">new</span> SlideId());</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum18" style="color:#606060;">  18:</span>             newSlideId.Id = slideId;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum19" style="color:#606060;">  19:</span>             newSlideId.RelationshipId = pPart.GetIdOfPart(sPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum20" style="color:#606060;">  20:</span>         }</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Since the presentation started with only a slide master in the template and no slides, a SlideIdList must be added to the PresentationPart.  Then start adding slides, using the layout names from the slide master.  Notice that the slide IDs were started at 256, that’s not a typo.  Slide IDs must be &gt;= 256.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum1" style="color:#606060;">   1:</span> <span style="color:#0000ff;">using</span> (PresentationDocument pDoc = PresentationDocument.Open(newFileCopiedFromTemplate, <span style="color:#0000ff;">true</span>))</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum2" style="color:#606060;">   2:</span>             {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum3" style="color:#606060;">   3:</span>                 PresentationPart pPart = pDoc.PresentationPart;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum4" style="color:#606060;">   4:</span> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum5" style="color:#606060;">   5:</span>                 pPart.Presentation.SlideIdList = <span style="color:#0000ff;">new</span> SlideIdList();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum6" style="color:#606060;">   6:</span>                 InsertSlide(pPart, <span style="color:#006080;">"Layout1"</span>, 256);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum7" style="color:#606060;">   7:</span>                 InsertSlide(pPart, <span style="color:#006080;">"Layout3"</span>, 257);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum8" style="color:#606060;">   8:</span>                 InsertSlide(pPart, <span style="color:#006080;">"Layout3"</span>, 258);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum9" style="color:#606060;">   9:</span>                 InsertSlide(pPart, <span style="color:#006080;">"Layout2"</span>, 259);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum10" style="color:#606060;">  10:</span>                 pPart.Presentation.Save();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;"><span id="lnum11" style="color:#606060;">  11:</span>                 pDoc.Close();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;"><span id="lnum12" style="color:#606060;">  12:</span>             }</pre>
<p><!--CRLF--></p>
</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=41&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/03/24/creating-new-presentations-using-the-slide-master/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/57649c22ae11bdbf2eaf910c5116a41a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kaark</media:title>
		</media:content>
	</item>
		<item>
		<title>Open XML SDK 2 Released</title>
		<link>http://codingthedocument.wordpress.com/2010/03/24/open-xml-sdk-2-released/</link>
		<comments>http://codingthedocument.wordpress.com/2010/03/24/open-xml-sdk-2-released/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 12:19:35 +0000</pubDate>
		<dc:creator>Tim Murphy</dc:creator>
				<category><![CDATA[Office Open XML]]></category>

		<guid isPermaLink="false">http://codingthedocument.wordpress.com/2010/03/24/open-xml-sdk-2-released/</guid>
		<description><![CDATA[This post is a little late since the SDK was released about a week ago.&#160; At PSC we have been using the Open XML SDK 2 since its earliest beta.&#160; It is a very powerful tool for generating documents without using the Office DLLs.&#160; It is also the main technology that I have been working [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=40&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post is a little late since the SDK was released about a week ago.&#160; At PSC we have been using the Open XML SDK 2 since its earliest beta.&#160; It is a very powerful tool for generating documents without using the Office DLLs.&#160; It is also the main technology that I have been working with for the last six months.&#160; I would suggest giving it a try.&#160; </p>
<p>Stay tuned here.&#160; In the near future I will be presenting at different locations on this and other document generation technologies.</p>
<p>Download the Open XML SDK <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0" target="_blank">here</a>.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1a769c7c-81da-43d0-8138-7f802b8842c3" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/Office+Open+XML" rel="tag">Office Open XML</a>,<a href="http://del.icio.us/popular/Open+XML+SDK+2" rel="tag">Open XML SDK 2</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=40&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/03/24/open-xml-sdk-2-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1436727bb92bde90faae268f7330bcef?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tmurphy</media:title>
		</media:content>
	</item>
		<item>
		<title>Copying A Slide From One Presentation To Another</title>
		<link>http://codingthedocument.wordpress.com/2010/03/20/copying-a-slide-from-one-presentation-to-another/</link>
		<comments>http://codingthedocument.wordpress.com/2010/03/20/copying-a-slide-from-one-presentation-to-another/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 21:26:18 +0000</pubDate>
		<dc:creator>Tim Murphy</dc:creator>
				<category><![CDATA[Office Open XML]]></category>
		<category><![CDATA[VSTO]]></category>

		<guid isPermaLink="false">http://codingthedocument.wordpress.com/2010/03/20/copying-a-slide-from-one-presentation-to-another/</guid>
		<description><![CDATA[There are many ways to generate a PowerPoint presentation using Open XML.&#160; The first way is to build it by hand strictly using the SDK.&#160; Alternately you can modify a copy of a base presentation in place.&#160; The third approach to generate a presentation is to build a new presentation from the parts of an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=37&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are many ways to generate a PowerPoint presentation using Open XML.&#160; The first way is to build it by hand strictly using the SDK.&#160; Alternately you can modify a copy of a base presentation in place.&#160; The third approach to generate a presentation is to build a new presentation from the parts of an existing presentation by copying slides as needed.&#160; This post will focus on the third option.</p>
<p>In order to make this solution a little more elegant I am going to create a VSTO add-in as I did in my previous post.&#160; This one is going to insert Tags to identify slides instead of NonVisualDrawingProperties which I used to identify charts, tables and images.&#160; The code itself is fairly short.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">SlideNameForm dialog = <span style="color:#0000ff;">new</span> SlideNameForm();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">Selection selection = Globals.ThisAddIn.Application.ActiveWindow.Selection;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">if</span>(dialog.ShowDialog() == DialogResult.OK)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    selection.SlideRange.Tags.Add(dialog.slideName,dialog.slideName);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">}</pre>
<p><!--CRLF--></div>
</div>
<p><!--CRLF--></p>
<p>Zeyad Rajabi has a good post <a href="http://blogs.msdn.com/brian_jones/archive/2009/03/05/how-to-assemble-multiple-powerpoint-decks.aspx">here</a> on combining slides from two presentations.&#160; The example he gives is great if you are doing a straight merge.&#160; But what if you want to use your source file as almost a supermarket where you pick and chose slides and may even insert them repeatedly?&#160; The following code uses the tags we created in the previous step to pick a particular slide an copy it to a destination file.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">using</span> (PresentationDocument newDocument = PresentationDocument.Open(OutputFileText.Text,<span style="color:#0000ff;">true</span>))</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    PresentationDocument templateDocument = PresentationDocument.Open(FileNameText.Text, <span style="color:#0000ff;">false</span>);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    uniqueId = GetMaxIdFromChild(newDocument.PresentationPart.Presentation.SlideMasterIdList);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">uint</span> maxId = GetMaxIdFromChild(newDocument.PresentationPart.Presentation.SlideIdList);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    SlidePart oldPart = GetSlidePartByTagName(templateDocument, SlideToCopyText.Text);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    SlidePart newPart = newDocument.PresentationPart.AddPart&lt;SlidePart&gt;(oldPart, <span style="color:#006080;">&quot;sourceId1&quot;</span>);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    SlideMasterPart newMasterPart = newDocument.PresentationPart.AddPart(newPart.SlideLayoutPart.SlideMasterPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    SlideIdList idList = newDocument.PresentationPart.Presentation.SlideIdList;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">// create new slide ID</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    maxId++;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    SlideId newId = <span style="color:#0000ff;">new</span> SlideId();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    newId.Id = maxId;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    newId.RelationshipId = <span style="color:#006080;">&quot;sourceId1&quot;</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    idList.Append(newId);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">// Create new master slide ID</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    uniqueId++;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    SlideMasterId newMasterId = <span style="color:#0000ff;">new</span> SlideMasterId();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    newMasterId.Id = uniqueId;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    newMasterId.RelationshipId = newDocument.PresentationPart.GetIdOfPart(newMasterPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    newDocument.PresentationPart.Presentation.SlideMasterIdList.Append(newMasterId);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">// change slide layout ID</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    FixSlideLayoutIds(newDocument.PresentationPart);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">//newPart.Slide.Save();</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    newDocument.PresentationPart.Presentation.Save();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">}</pre>
<p><!--CRLF--></div>
</div>
<p>The GetMaxIDFromChild and FixSlideLayoutID methods are barrowed from Zeyad’s article.&#160; The GetSlidePartByTagName method is listed below.&#160; It is really one LINQ query that finds SlideParts with child Tags that have the requested Name.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> SlidePart GetSlidePartByTagName(PresentationDocument templateDocument, <span style="color:#0000ff;">string</span> tagName)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">return</span> (from p <span style="color:#0000ff;">in</span> templateDocument.PresentationPart.SlideParts</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">where</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                p.UserDefinedTagsParts.First().TagList.Descendants</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                    &lt;DocumentFormat.OpenXml.Presentation.Tag&gt;().First().Name ==</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                tagName.ToUpper()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            select p).First();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">}</pre>
<p><!--CRLF--></div>
</div>
<p>This is what really makes the difference from what Zeyad posted.&#160; The most powerful thing you can have when generating documents from templates is a consistent way of naming items to be manipulated.&#160; I will be show more approaches like this in upcoming posts.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:bc98459b-79b0-4492-b98f-338a0a694774" class="wlWriterEditableSmartContent">del.icio.us Tags: <a href="http://del.icio.us/popular/Office+Open+XML" rel="tag">Office Open XML</a>,<a href="http://del.icio.us/popular/Presentation" rel="tag">Presentation</a>,<a href="http://del.icio.us/popular/PowerPoint" rel="tag">PowerPoint</a>,<a href="http://del.icio.us/popular/VSTO" rel="tag">VSTO</a>,<a href="http://del.icio.us/popular/TagList" rel="tag">TagList</a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=37&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/03/20/copying-a-slide-from-one-presentation-to-another/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1436727bb92bde90faae268f7330bcef?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tmurphy</media:title>
		</media:content>
	</item>
		<item>
		<title>Naming PowerPoint Components With A VSTO Add-In</title>
		<link>http://codingthedocument.wordpress.com/2010/03/11/naming-powerpoint-components-with-a-vsto-add-in/</link>
		<comments>http://codingthedocument.wordpress.com/2010/03/11/naming-powerpoint-components-with-a-vsto-add-in/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 04:25:27 +0000</pubDate>
		<dc:creator>Tim Murphy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codingthedocument.wordpress.com/2010/03/11/naming-powerpoint-components-with-a-vsto-add-in/</guid>
		<description><![CDATA[Sometimes in order to work with Open XML we need a little help from other tools.&#160; In this post I am going to describe&#160; a fairly simple solution for marking up PowerPoint presentations so that they can be used as templates and processed using the Open XML SDK. Add-ins are tools which it can be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=31&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes in order to work with Open XML we need a little help from other tools.&#160; In this post I am going to describe&#160; a fairly simple solution for marking up PowerPoint presentations so that they can be used as templates and processed using the Open XML SDK.</p>
<p>Add-ins are tools which it can be hard to find information on.&#160; I am going to up the obscurity by adding a Ribbon button.&#160; For my example I am using Visual Studio 2008 and creating a PowerPoint 2007 Add-in project.&#160; To that add a Ribbon Visual Designer.&#160; The new ribbon by default will show up on the Add-in tab.</p>
<p>Add a button to the ribbon.&#160; Also add a WinForm to collect a new name for the object selected.&#160; Make sure to set the OK button’s DialogResult to OK. In the ribbon button click event add the following code.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">ObjectNameForm dialog = <span style="color:#0000ff;">new</span> ObjectNameForm();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">Selection selection = Globals.ThisAddIn.Application.ActiveWindow.Selection;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">dialog.objectName = selection.ShapeRange.Name;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">if</span> (dialog.ShowDialog() == DialogResult.OK)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    selection.ShapeRange.Name = dialog.objectName;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">}</pre>
<p><!--CRLF--></div>
</div>
<p>This code will first read the current Name attribute of the Shape object.&#160; If the user clicks OK on the dialog it save the string value back to the same place.</p>
<p>Once it is done you can retrieve identify the control through Open XML via the NonVisualDisplayProperties objects.&#160; The only problem is that this object is a child of several different classes.&#160; This means that there isn’t just one way to retrieve the value.&#160; Below are a couple of pieces of code to identify the container that you have named.</p>
<p>The first example is if you are naming placeholders in a layout slide.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">foreach</span>(var slideMasterPart <span style="color:#0000ff;">in</span> slideMasterParts)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    var layoutParts =  slideMasterPart.SlideLayoutParts;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">foreach</span>(SlideLayoutPart slideLayoutPart <span style="color:#0000ff;">in</span> layoutParts)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">foreach</span> (assmPresentation.Shape shape <span style="color:#0000ff;">in</span> slideLayoutPart.SlideLayout.CommonSlideData.ShapeTree.Descendants&lt;assmPresentation.Shape&gt;())</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            var slideMasterProperties =</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                from p <span style="color:#0000ff;">in</span> shape.Descendants&lt;assmPresentation.NonVisualDrawingProperties&gt;()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                <span style="color:#0000ff;">where</span> p.Name == TokenText.Text</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                select p;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">if</span> (slideMasterProperties.Count() &gt; 0)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                tokenFound = <span style="color:#0000ff;">true</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">}</pre>
<p><!--CRLF--></div>
</div>
<p>The second example allows you to find charts that you have named with the add-in.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">foreach</span>(var slidePart <span style="color:#0000ff;">in</span> slideParts)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">{</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">foreach</span>(assmPresentation.Shape slideShape <span style="color:#0000ff;">in</span> slidePart.Slide.CommonSlideData.ShapeTree.Descendants&lt;assmPresentation.Shape&gt;())</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        var slideProperties = from g <span style="color:#0000ff;">in</span> slidePart.Slide.Descendants&lt;GraphicFrame&gt;()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">where</span> g.NonVisualGraphicFrameProperties.NonVisualDrawingProperties.Name == TokenText.Text</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            select g;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span>(slideProperties.Count() &gt; 0)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            tokenFound = <span style="color:#0000ff;">true</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">}</pre>
<p><!--CRLF--></div>
</div>
<p>Together the combination of Open XML and VSTO add-ins make a powerful combination in creating a process for maintaining a template and generating documents from the template.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=31&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/03/11/naming-powerpoint-components-with-a-vsto-add-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1436727bb92bde90faae268f7330bcef?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tmurphy</media:title>
		</media:content>
	</item>
		<item>
		<title>Bolding and Underlining Text In Word Documents</title>
		<link>http://codingthedocument.wordpress.com/2010/02/16/bolding-and-underlining-text-in-word-documents/</link>
		<comments>http://codingthedocument.wordpress.com/2010/02/16/bolding-and-underlining-text-in-word-documents/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 17:43:04 +0000</pubDate>
		<dc:creator>Tim Murphy</dc:creator>
				<category><![CDATA[Office Open XML]]></category>

		<guid isPermaLink="false">http://codingthedocument.wordpress.com/2010/02/16/bolding-and-underlining-text-in-word-documents/</guid>
		<description><![CDATA[In the templates that I have processed with Open XML there are usually a number of tables.  Some times we have to add an extra paragraph to a cell and we want to keep the formatting of the text already in the cell.  In this post I will go over how to apply bold and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=28&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the templates that I have processed with Open XML there are usually a number of tables.  Some times we have to add an extra paragraph to a cell and we want to keep the formatting of the text already in the cell.  In this post I will go over how to apply bold and underline formatting to text as well as how to steal it from existing text and apply it to a new paragraph or run.</p>
<p>In order to apply an underline format to a paragraph by hand you have to start with the ParagraphProperties.  To that you append a ParagraphMarkRunProperties object to which you have appended an Underline object.  It isn’t that complicated.  There are just a lot of objects that have to be instantiated to format a paragraph.  Below is an example of what I have just described.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">Paragraph newParagraph = <span style="color:#0000ff;">new</span> Paragraph();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">ParagraphProperties newProperties = <span style="color:#0000ff;">new</span> ParagraphProperties();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">ParagraphMarkRunProperties markRunProperties = <span style="color:#0000ff;">new</span> ParagraphMarkRunProperties();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">Underline newUnderline = <span style="color:#0000ff;">new</span> Underline { Val = UnderlineValues.Single };</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">markRunProperties.AppendChild(newUnderline);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">newProperties.AppendChild(markRunProperties);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"> </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">newParagraph.AppendChild(newProperties);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">wordprocessing.Run newRun = <span style="color:#0000ff;">new</span> wordprocessing.Run();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">wordprocessing.Text newText = <span style="color:#0000ff;">new</span> wordprocessing.Text(<span style="color:#006080;">"Text for the new paragraph"</span>);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">newRun.AppendChild(newText);</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>In order to make a paragraph or run bold you append a Bold object instead of or as well as the Underline object.</p>
<p>If you have an existing paragraph that you can steal from the code gets a lot easier.  The code below does just that by cloning the ParagraphProperties from the existing paragraph and appending it to the new paragraph.</p>
<div id="codeSnippetWrapper" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:'Courier New', courier, monospace;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;cursor:text;border:silver 1px solid;margin:20px 0 10px;padding:4px;">
<div id="codeSnippet" style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">ParagraphProperties properties = (ParagraphProperties)oldParagraph.ParagraphProperties.Clone();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">newParagraph.AppendChild(props);</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Of course which approach you take will depend on what you situation is.  If you are allowing a user to define formatting through an interface other than a template you will have to use the first example.  This is one more reason to use a base file as a template.  Either way you should be able to accomplish the goal of formatting your text.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingthedocument.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingthedocument.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingthedocument.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingthedocument.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codingthedocument.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codingthedocument.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codingthedocument.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codingthedocument.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingthedocument.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingthedocument.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingthedocument.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingthedocument.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingthedocument.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingthedocument.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingthedocument.wordpress.com&amp;blog=11061574&amp;post=28&amp;subd=codingthedocument&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codingthedocument.wordpress.com/2010/02/16/bolding-and-underlining-text-in-word-documents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1436727bb92bde90faae268f7330bcef?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tmurphy</media:title>
		</media:content>
	</item>
	</channel>
</rss>
