<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Beth Massi - Sharing the goodness that is VB : XML</title><link>http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx</link><description>Tags: XML</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Silicon Valley Code Camp Oct. 3-4 : Schedule is up!</title><link>http://blogs.msdn.com/bethmassi/archive/2009/09/28/silicon-valley-code-camp-oct-3-4-schedule-is-up.aspx</link><pubDate>Mon, 28 Sep 2009 22:37:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9900417</guid><dc:creator>Beth Massi</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9900417.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9900417</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9900417</wfw:comment><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/08/27/come-to-silicon-valley-code-camp-october-3rd-4th.aspx" target="_blank"&gt;As I mentioned before&lt;/a&gt;, I’ll be speaking this weekend at Silicon Valley Code Camp (&lt;a href="http://siliconvalley-codecamp.com/"&gt;http://siliconvalley-codecamp.com/&lt;/a&gt;). This is a FREE event at at &lt;a href="http://siliconvalley-codecamp.com/Venue.aspx"&gt;Foothill College&lt;/a&gt; and it’s not just Microsoft technologies. A lot of great speakers will be there too. &lt;/p&gt;  &lt;p&gt;The &lt;a href="http://siliconvalley-codecamp.com/SessionsOverview.aspx" target="_blank"&gt;schedule is up so check it out&lt;/a&gt; and mark the ones you plan on attending. I’ll be presenting two sessions on Saturday:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://siliconvalley-codecamp.com/Sessions.aspx?ForceSortBySessionTime=true&amp;amp;id=190"&gt;Future Directions for Microsoft Visual Basic and C#&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://siliconvalley-codecamp.com/Sessions.aspx?ForceSortBySessionTime=true&amp;amp;id=190"&gt;Taking Advantage of LINQ and XML in Office 2007&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Also on Sunday there will be a &lt;a href="http://siliconvalley-codecamp.com/Sessions.aspx?track=3" target="_blank"&gt;Cloud Camp Unconference&lt;/a&gt; where early adopters of cloud computing technologies can exchange ideas and give insight on how to plan for and take advantage of cloud computing. &lt;/p&gt;  &lt;p&gt;There are already over 1300 people registered so it’s sure to be a great event. &lt;strong&gt;&lt;a href="http://siliconvalley-codecamp.com/Register.aspx" target="_blank"&gt;Register today!&lt;/a&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;See you this weekend!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9900417" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Speaking/default.aspx">Speaking</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2010/default.aspx">VS2010</category></item><item><title>Merging Text &amp; Photos into a Word Document using Open XML SDK</title><link>http://blogs.msdn.com/bethmassi/archive/2009/09/24/merging-text-photos-into-a-word-document-using-open-xml-sdk.aspx</link><pubDate>Fri, 25 Sep 2009 00:55:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9899172</guid><dc:creator>Beth Massi</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9899172.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9899172</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9899172</wfw:comment><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/09/23/mail-merging-into-a-single-word-document-using-xml-literals.aspx" target="_blank"&gt;Yesterday I posted&lt;/a&gt; about how we could create a letter generator (mail merge) that took data from a database to create a Word 2007 document using the System.IO.Packaging class. I showed how to take data from Northwind using a single LINQ query to create XDocument objects representing letters to customers and then create a single document of all the data using XML Literals. &lt;/p&gt; &lt;p&gt;Today I want to show how we can embed images into the documents as well as text. Since we’re using Northwind for this example, we’ll use the Employee.Photo field from that database. &lt;/p&gt; &lt;p&gt;&lt;strong&gt;The Letter Template with Photo&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;The first thing to do is create a letter template with our field placeholders as well as an image placeholder. We’ll also need to insert a page break at the end because we’re going to merge all the letters into a single document for easy printing:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MergingTextPhotosintoaSingleWordDocument_E6F4/image_2.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MergingTextPhotosintoaSingleWordDocument_E6F4/image_thumb.png" width="668" height="555"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;The next step is to grab the document.xml from this docx file. Because it’s an Open XML package, as I showed in &lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/09/23/mail-merging-into-a-single-word-document-using-xml-literals.aspx" target="_blank"&gt;yesterday’s post&lt;/a&gt;, we can just rename this file with a .zip extension temporarily and drill into the word\document.xml. However, there’s an easier way to work with these packages by installing the &lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/07/29/handy-visual-studio-add-in-to-view-office-2007-files.aspx" target="_blank"&gt;Open XML package editor&lt;/a&gt; Visual Studio add-in from the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" target="_blank"&gt;VSTO Power Tools download&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MergingTextPhotosintoaSingleWordDocument_E6F4/image_8.png" target="_blank"&gt;&lt;img style="border-right-width: 0px; margin: 0px 10px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MergingTextPhotosintoaSingleWordDocument_E6F4/image_thumb_3.png" width="457" height="327"&gt;&lt;/a&gt;Once you install the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" target="_blank"&gt;VSTO Power tools&lt;/a&gt;, save this template in your project. Then you can just double-click on the .docx file in the Solution Explorer and it will open the package editor (it also works with .pptx and .xslx files). Now you can drill into the document.xml directly in Visual Studio and inspect all the parts of the package easily. &lt;/p&gt; &lt;p&gt;The difference between this template and the template we used yesterday is there is an image imbedded into the document. So you will see an image embedded into the package in the media folder. This is referred to as an “image part”. This part is linked to the “main document part” which is the word\document.xml file. The Open XML package editor shows the links (relationships) to all the parts. When you look at the relationship properties you’ll see that it has a unique ID. This is the same ID that you will see in the main document part at the point where we embedded the image, in our case it’s set to &lt;strong&gt;rId4&lt;/strong&gt;. (I’ve omitted all the WordProccessingML for clarity):&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #a31515"&gt;xml &lt;/span&gt;&lt;span style="color: red"&gt;version&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1.0&lt;/span&gt;" &lt;span style="color: red"&gt;encoding&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;utf-8&lt;/span&gt;" &lt;span style="color: red"&gt;standalone&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;yes&lt;/span&gt;"&lt;span style="color: blue"&gt;?&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:document ...&lt;br&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:body&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; ...&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:drawing&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; ...&lt;br&gt;&lt;/pre&gt;&lt;/span&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;              &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:graphic &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:a&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http://schemas.openxmlformats.org/drawingml/2006/main&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
              &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:graphicData &lt;/span&gt;&lt;span style="color: red"&gt;uri&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http://schemas.openxmlformats.org/drawingml/2006/picture&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:pic &lt;/span&gt;&lt;span style="color: red"&gt;xmlns:pic&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http://schemas.openxmlformats.org/drawingml/2006/picture&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
                  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:nvPicPr&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:cNvPr &lt;/span&gt;&lt;span style="color: red"&gt;id&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;0&lt;/span&gt;" &lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;image1.png&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:cNvPicPr&lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
                  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:nvPicPr&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:blipFill&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:blip &lt;/span&gt;&lt;strong&gt;&lt;span style="color: red"&gt;r:embed&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;rId4&lt;/span&gt;"&lt;/strong&gt; &lt;span style="color: red"&gt;cstate&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;print&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:stretch&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:fillRect&lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:stretch&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:blipFill&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:spPr&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:xfrm&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:off &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;0&lt;/span&gt;" &lt;span style="color: red"&gt;y&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;0&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
                      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:ext &lt;/span&gt;&lt;span style="color: red"&gt;cx&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;1829055&lt;/span&gt;" &lt;span style="color: red"&gt;cy&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;2124372&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:xfrm&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:prstGeom &lt;/span&gt;&lt;span style="color: red"&gt;prst&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;rect&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
                      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:avLst&lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:prstGeom&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:spPr&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;pic:pic&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
              &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:graphicData&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;a:graphic&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; ...
          &lt;/span&gt;&lt;span style="color: blue"&gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:drawing&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; ...&lt;br&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:p &lt;/span&gt;&lt;span style="color: red"&gt;w:rsidR&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;00622A50&lt;/span&gt;" &lt;span style="color: red"&gt;w:rsidRDefault&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;00622A50&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;
            &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:r&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
                &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:br &lt;/span&gt;&lt;span style="color: red"&gt;w:type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;page&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;
            &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:r&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
        &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:p&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; ...&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:body&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;w:document&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;strong&gt;Installing the Open XML SDK&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As I mentioned yesterday, manipulating the package directly with the System.IO.Packaging classes gets a little bit tricky when you have to start adding embedded images and objects and linking them together. Instead, it’s easier to use the Open XML SDK to do this because it will handle linking new image parts we add to the package automatically for us. The SDK provides a strongly-typed way of accessing the parts in a package so it cuts down on the amount of code you have to write yourself.&amp;nbsp; Version 1.0 requires only .NET 2.0, Version 2 requires .NET 3.5 and uses LINQ to provide more functionality when querying the parts. This version is currently a CTP. For what we’re doing you can use either version but I have Version 2 installed. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=AD0B72FB-4A1D-4C52-BDB5-7DD7E816D046&amp;amp;displaylang=en" target="_blank"&gt;Download Open XML Format SDK 1.0&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" target="_blank"&gt;Download Open XML Format SDK 2.0&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The assembly that is installed in the GAC when you install the SDK is called DocumentFormat.OpenXml.dll and you’ll need to add a project reference to this. When you distribute your application you can simply xcopy the assembly with your application for easy deployment. (After you add the reference, select it in the Server Explorer and then in the Properties window set Copy Local to True in order to have it outputted to the \bin folder when you build your application.)&lt;/p&gt;
&lt;p&gt;Now we can add the namespace imports we’ll be working with at the top of our program, including the DocumentFormat.OpenXml.Packaging namespace:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Imports &lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #b96464"&gt;xmlns:w&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;http://schemas.openxmlformats.org/wordprocessingml/2006/main&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;Imports &lt;/span&gt;System.Xml
&lt;span style="color: blue"&gt;Imports &lt;/span&gt;System.IO
&lt;span style="color: blue"&gt;Imports &lt;/span&gt;DocumentFormat.OpenXml.Packaging&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;strong&gt;Modifying the Letter Class and LINQ Query to Get the Photo&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In order to create letters for our customers in the database, we want to end up with a collection of XDocuments with our data merged into them. I created a Letter class that has two properties, CustomerID As String and Document As XDocument. We’re also going to add a new property for the photo byte array called EmployeePhoto As Byte() and OrderID as Integer. Next we need to modify the query so that it selects the photo as well as add the above WordProcessingML into our XML Literal to specify where the image should appear in the document. Because the relationship IDs must be unique, I’m going to use the OrderID as the suffix for the relationship ID for each of the images we want to embed. Like before, we can use embedded expressions to merge the data into the right places in the XDocument. 
&lt;p&gt;(I’ve omitted all the XML with the embedded expressions for clarity, take a loot at &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=openxmlvb&amp;amp;DownloadId=7325"&gt;the code sample&lt;/a&gt; for the whole listing.) The bolded areas show the modified sections of the query:&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;letters = _
&lt;span style="color: blue"&gt;  From &lt;/span&gt;Order &lt;span style="color: blue"&gt;In &lt;/span&gt;db.Orders _
&lt;span style="color: blue"&gt;  Join &lt;/span&gt;Employee &lt;span style="color: blue"&gt;In &lt;/span&gt;db.Employees _
&lt;span style="color: blue"&gt;    On &lt;/span&gt;Order.EmployeeID &lt;span style="color: blue"&gt;Equals &lt;/span&gt;Employee.EmployeeID _
&lt;span style="color: blue"&gt;  Where &lt;/span&gt;Order.OrderDate &lt;span style="color: blue"&gt;IsNot Nothing AndAlso &lt;/span&gt;_
    Order.ShippedDate &lt;span style="color: blue"&gt;IsNot Nothing AndAlso &lt;/span&gt;_
    Order.ShippedDate.Value.Date &amp;gt;= #1/1/1998# _
&lt;span style="color: blue"&gt;  Let &lt;/span&gt;DateOrder = Order.OrderDate.Value.ToShortDateString _
&lt;span style="color: blue"&gt;  Let &lt;/span&gt;DateShip = Order.ShippedDate.Value.ToShortDateString _
&lt;span style="color: blue"&gt;  Select New &lt;/span&gt;Letter &lt;span style="color: blue"&gt;With &lt;/span&gt;{ _
    .CustomerID = Order.CustomerID, _&lt;br&gt;    &lt;strong&gt;.OrderID = Order.OrderID, _
&lt;br&gt;&lt;br&gt;&lt;br&gt;    .EmployeePhoto = &lt;span style="color: blue"&gt;If&lt;/span&gt;(Employee.Photo &lt;span style="color: blue"&gt;IsNot Nothing&lt;/span&gt;, Employee.Photo.ToArray, &lt;span style="color: blue"&gt;Nothing&lt;/span&gt;), _&lt;/strong&gt;
    .Document = &lt;span style="color: #6464b9"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #844646"&gt;xml &lt;/span&gt;&lt;span style="color: #b96464"&gt;version&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;1.0&lt;/span&gt;&lt;span style="color: #555555"&gt;" &lt;/span&gt;&lt;span style="color: #b96464"&gt;encoding&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;utf-8&lt;/span&gt;&lt;span style="color: #555555"&gt;" &lt;/span&gt;&lt;span style="color: #b96464"&gt;standalone&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;yes&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;?&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:document ... &lt;br&gt;&lt;/span&gt;&lt;span style="color: #6464b9"&gt;            &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:body&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt; ...
&lt;/span&gt;&lt;span style="color: #6464b9"&gt;                &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:p &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:rsidR&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;00A9498E&lt;/span&gt;&lt;span style="color: #555555"&gt;" &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:rsidRDefault&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;00A9498E&lt;/span&gt;&lt;span style="color: #555555"&gt;" &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:rsidP&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;00AA2EC6&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t &lt;/span&gt;&lt;span style="color: #b96464"&gt;xml:space&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;preserve&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #555555"&gt;If you have any issues please contact &lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:proofErr &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:type&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;spellStart&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;/&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: #fffebf; color: #555555"&gt;&amp;lt;%=&lt;/span&gt; Employee.FirstName &amp;amp; &lt;span style="color: #a31515"&gt;" " &lt;/span&gt;&amp;amp; Employee.LastName &lt;span style="background: #fffebf; color: #555555"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                    &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:proofErr &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:type&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;spellEnd&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;/&amp;gt;
                        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                            &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t &lt;/span&gt;&lt;span style="color: #b96464"&gt;xml:space&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;preserve&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: #555555"&gt;at&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:rsidR&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;005F35D6&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                            &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t &lt;/span&gt;&lt;span style="color: #b96464"&gt;xml:space&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;preserve&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt; &lt;/span&gt;&lt;span style="color: #555555"&gt;ext.&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                            &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t &lt;/span&gt;&lt;span style="color: #b96464"&gt;xml:space&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;preserve&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:rsidR&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;005F35D6&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                            &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background: #fffebf; color: #555555"&gt;&amp;lt;%=&lt;/span&gt; Employee.Extension &lt;span style="background: #fffebf; color: #555555"&gt;%&amp;gt;&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:t&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:p&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt; ...
                        &lt;/span&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:drawing&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;&amp;gt; ...
&lt;/span&gt;&lt;span style="color: #6464b9"&gt;                            &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;pic:blipFill&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;&amp;gt; ...
                                &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;a:blip &lt;/span&gt;&lt;span style="color: #b96464"&gt;r:embed&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="background: #fffebf; color: #555555"&gt;&amp;lt;%=&lt;/span&gt; &lt;/strong&gt;&lt;span style="color: #a31515"&gt;"rId" &lt;/span&gt;&amp;amp; &lt;strong&gt;Order.OrderID &lt;span style="background: #fffebf; color: #555555"&gt;%&amp;gt;&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;/&amp;gt; ...
&lt;/span&gt;&lt;span style="color: #6464b9"&gt;                        &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:drawing&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;&amp;gt; ...
&lt;/span&gt;&lt;span style="color: #6464b9"&gt;                        &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:p &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:rsidR&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;00622A50&lt;/span&gt;&lt;span style="color: #555555"&gt;" &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:rsidRDefault&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;00622A50&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                            &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                                &amp;lt;&lt;/span&gt;&lt;span style="color: #844646"&gt;w:br &lt;/span&gt;&lt;span style="color: #b96464"&gt;w:type&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;span style="color: #6464b9"&gt;page&lt;/span&gt;&lt;span style="color: #555555"&gt;"&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;/&amp;gt;
                            &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:r&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                        &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:p&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: #6464b9"&gt;&lt;strong&gt;&amp;gt; ...&lt;/strong&gt;
&lt;/span&gt;&lt;span style="color: #6464b9"&gt;                    &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:body&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;
                &amp;lt;/&lt;/span&gt;&lt;span style="color: #844646"&gt;w:document&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;}&lt;/pre&gt;
&lt;p&gt;The query returns an IEnumerable(Of Letter) objects with the Document property set to the document.xml data for that customer and the EmployeePhoto set to the photo byte array. If we wanted to create separate documents (which is exactly what I demonstrated in my &lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/08/17/devproconnections-article-taking-advantage-of-linq-and-xml-in-microsoft-office-2007.aspx" target="_blank"&gt;DevProConnections article&lt;/a&gt;) it’s actually pretty simple because all we need to do is copy the template and then replace the document.xml and the image data, we don’t have to mess with the relationship ID at all. However if we want to create a single document with all our letters we need to delete the placeholder image part and add new unique image parts for the Letter.EmployeePhoto. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Adding and Linking the Images into a Single Word Document&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Because relationship IDs must be unique in a document I used the OrderID as the embedded expression for the r:embed attribute in the XML Literal above. You can choose to use any unique ID you want but it must start with an alpha character, that’s why I prefixed it with “rId”. When you use the Open XML SDK to add the new image parts we have to specify the relationship ID to use. To update the code we wrote yesterday to work with the Open XML SDK and also work with images we first need to add a call to open the Word document template, grab the main document part and then delete the image part by calling DeletePart:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: green"&gt;'Place the letters in a separate directory
&lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;sourceFile = CurDir() &amp;amp; &lt;span style="color: #a31515"&gt;"\LetterTemplate.docx"
&lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;letterDir = CurDir() &amp;amp; &lt;span style="color: #a31515"&gt;"\Letters\"
&lt;/span&gt;&lt;span style="color: blue"&gt;My&lt;/span&gt;.Computer.FileSystem.CreateDirectory(letterDir)

&lt;span style="color: blue"&gt;Dim &lt;/span&gt;mergeFile = letterDir &amp;amp; &lt;span style="color: #a31515"&gt;"AllLetters.docx"
&lt;/span&gt;&lt;span style="color: blue"&gt;My&lt;/span&gt;.Computer.FileSystem.CopyFile(sourceFile, mergeFile, &lt;span style="color: blue"&gt;True&lt;/span&gt;)

&lt;span style="color: green"&gt;'Open the Document template using the Open XML SDK
&lt;/span&gt;&lt;span style="color: blue"&gt;Using &lt;/span&gt;wordDoc = WordprocessingDocument.Open(mergeFile, &lt;span style="color: blue"&gt;True&lt;/span&gt;)

&lt;span style="color: green"&gt;    'get the main document part (document.xml)
    &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;mainPart = wordDoc.MainDocumentPart()

    &lt;span style="color: green"&gt;'Delete the placeholder image from the template so we can replace it with the real photos
    &lt;/span&gt;mainPart.DeletePart(&lt;span style="color: #a31515"&gt;"rId4"&lt;/span&gt;)&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;This opens the Word document as read/write and then deletes the placeholder image. You should also notice at this point that the code is a bit simpler to open the package than yesterday because we don’t have to declare the relative URI’s or content types. The Open XML SDK helps us here. Next we need to load the document.xml into an XElement object and grab the body:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;    Dim &lt;/span&gt;mainDocumentXML &lt;span style="color: blue"&gt;As &lt;/span&gt;XElement
    &lt;span style="color: blue"&gt;Using &lt;/span&gt;sr &lt;span style="color: blue"&gt;As New &lt;/span&gt;StreamReader(mainPart.GetStream)
        mainDocumentXML = XElement.Load(sr)
    &lt;span style="color: blue"&gt;End Using

    Dim &lt;/span&gt;mainBody = mainDocumentXML...&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;w:body&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.First()
    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;i = 0&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Now we can loop through all the letters, grab the body of those XDocuments and then add an image part. We need to specify the content type and the relationship ID that must match what we embedded in the XML Literal in our query. Then we can either replace the main document body with the first letter (overwrite our placeholder data) otherwise we append the rest of the letter contents into the document:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;    For Each &lt;/span&gt;letter &lt;span style="color: blue"&gt;In &lt;/span&gt;letters
        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;nextBody = letter.Document...&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;w:body&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.First()
        &lt;span&gt;'Add the new imagePart. The SDK takes care of linking this properly.
       &lt;strong&gt; Dim &lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;imagePart = mainPart.AddImagePart(&lt;span style="color: #a31515"&gt;"image/png"&lt;/span&gt;, &lt;span style="color: #a31515"&gt;"rId" &lt;/span&gt;&amp;amp; letter.OrderID)&lt;/strong&gt;

        &lt;span style="color: blue"&gt;If &lt;/span&gt;i = 0 &lt;span style="color: blue"&gt;Then
           &lt;/span&gt;&lt;span style="color: green"&gt;'Replace the first body contents in the template
           &lt;/span&gt;mainBody.ReplaceNodes(nextBody.Elements())
        &lt;span style="color: blue"&gt;Else
           &lt;/span&gt;&lt;span style="color: green"&gt;'Otherwise append the next letter contents
           &lt;/span&gt;mainBody.Add(nextBody.Elements())
        &lt;span style="color: blue"&gt;End If&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Next we need to feed the byte array data into the ImagePart. Note that since I’m using Northwind for this example there is an OLE header on those images that we must strip off that is 78 bytes. If you are using your own images stored in SQL Server you won’t have to do that:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: green"&gt;        'Now feed the byte array into the ImagePart
        &lt;/span&gt;&lt;span style="color: blue"&gt;If &lt;/span&gt;letter.EmployeePhoto &lt;span style="color: blue"&gt;IsNot Nothing Then
            &lt;/span&gt;&lt;span style="color: green"&gt;'Using ms As New System.IO.MemoryStream(letter.EmployeePhoto.ToArray)
            'NOTE: Northwind Photos have an OLE header on them that we must strip off.
            ' You don't have to do this if you are using your own SQL-server stored images
            &lt;/span&gt;&lt;span style="color: blue"&gt;Using &lt;/span&gt;ms &lt;span style="color: blue"&gt;As New &lt;/span&gt;System.IO.MemoryStream(letter.EmployeePhoto, 78, _
                                                   letter.EmployeePhoto.Length - 78)
                imagePart.FeedData(ms)
            &lt;span style="color: blue"&gt;End Using
        End If

        &lt;/span&gt;i += 1
    &lt;span style="color: blue"&gt;Next&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Now that we’ve built up the document XML, added our image parts and linked them properly, the final step is to replace the document part with our XML just like before:&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: green"&gt;    'Replace the document part with our XML
    &lt;/span&gt;&lt;span style="color: blue"&gt;Using &lt;/span&gt;sw &lt;span style="color: blue"&gt;As New &lt;/span&gt;StreamWriter(mainPart.GetStream(FileMode.Create))
        mainDocumentXML.Save(sw)
    &lt;span style="color: blue"&gt;End Using

End Using&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Now when we run the application you will see a single document with all the letters, including photos, that’s much easier to print than multiple files. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MergingTextPhotosintoaSingleWordDocument_E6F4/image_12.png" target="_blank"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MergingTextPhotosintoaSingleWordDocument_E6F4/image_thumb_5.png" width="687" height="255"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;There’s Always Room for Improvement&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;LINQ &amp;amp; Northwind savvy folks may notice that I’m actually creating duplicates of the employee photos. Since I’m flattening out the data in my query to have 1 photo per order there could be an unnecessary amount of duplicate images. This can cause the document to get bloated. To be more efficient we should reuse the relationship ID’s to the images if they are the same on multiple orders. One approach would be to modify the LINQ query and Letter object to select the EmployeePhoto and then have a collection of order &amp;amp; document data under that. I’ll leave that experiment up to you :-)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=openxmlvb&amp;amp;DownloadId=7325" target="_blank"&gt;Take a look at the full code listing for this example&lt;/a&gt; as well as the &lt;a href="http://code.msdn.microsoft.com/openxmlvb" target="_blank"&gt;complete project with other Open XML examples here on Code Gallery&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9899172" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>Mail Merging Into a Single Word Document Using XML Literals</title><link>http://blogs.msdn.com/bethmassi/archive/2009/09/23/mail-merging-into-a-single-word-document-using-xml-literals.aspx</link><pubDate>Thu, 24 Sep 2009 02:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9898711</guid><dc:creator>Beth Massi</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9898711.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9898711</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9898711</wfw:comment><description>&lt;P&gt;With the release of Microsoft Office 2007 we can work with a much simpler, standard, XML format called &lt;A href="http://www.ecma-international.org/publications/standards/Ecma-376.htm" target=_blank mce_href="http://www.ecma-international.org/publications/standards/Ecma-376.htm"&gt;Open XML&lt;/A&gt; which opens the door for many types of applications that cannot work via COM. What if you needed to build a scalable web service that processes many documents in high volume? What if you wanted to quickly read or write to these formats from a client application but wanted to have minimal dependencies on other applications? These types of programs do not want to require Microsoft Office be installed to run. The cool thing is you have the tools already with Visual Basic 2008. XML Literals are an easy way to manipulate any kind of XML, including Open XML.&lt;/P&gt;
&lt;P&gt;I’ve written before on how to use XML Literals to manipulate Word documents, if you missed them:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/bethmassi/archive/2009/08/17/devproconnections-article-taking-advantage-of-linq-and-xml-in-microsoft-office-2007.aspx" mce_href="http://blogs.msdn.com/bethmassi/archive/2009/08/17/devproconnections-article-taking-advantage-of-linq-and-xml-in-microsoft-office-2007.aspx"&gt;&lt;STRONG&gt;DevProConnections Article: Taking Advantage of LINQ and XML in Microsoft Office 2007&lt;/STRONG&gt;&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Sample: &lt;A href="http://code.msdn.microsoft.com/openxmlvb" mce_href="http://code.msdn.microsoft.com/openxmlvb"&gt;Working with Open XML in Visual Basic&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/bethmassi/archive/2009/02/12/oba-part-3-storing-and-reading-data-in-word-documents.aspx" mce_href="http://blogs.msdn.com/bethmassi/archive/2009/02/12/oba-part-3-storing-and-reading-data-in-word-documents.aspx"&gt;OBA Part 3 - Storing and Reading Data in Word Documents&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/bethmassi/archive/2008/07/30/accessing-openxml-document-parts-with-the-openxml-sdk.aspx" mce_href="http://blogs.msdn.com/bethmassi/archive/2008/07/30/accessing-openxml-document-parts-with-the-openxml-sdk.aspx"&gt;Accessing Open XML Document Parts with the Open XML SDK&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/bethmassi/archive/2007/12/06/mail-merging-with-word-and-linq-to-xml-in-vb.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2007/12/06/mail-merging-with-word-and-linq-to-xml-in-vb.aspx"&gt;Mail Merging with Word, LINQ and XML Literals in VB&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If you aren’t familiar with XML Literals or Open XML then I’d suggest reading the article &lt;A href="http://blogs.msdn.com/bethmassi/archive/2009/08/17/devproconnections-article-taking-advantage-of-linq-and-xml-in-microsoft-office-2007.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2009/08/17/devproconnections-article-taking-advantage-of-linq-and-xml-in-microsoft-office-2007.aspx"&gt;in the first bullet above&lt;/A&gt; first. It’s a great intro into XML Literals, Open XML and it also demonstrates a couple practical ways of reading and writing to Word document formats directly. &lt;/P&gt;
&lt;P&gt;Recently I got a great question on how to change the program outlined in the &lt;A href="http://blogs.msdn.com/bethmassi/archive/2007/12/06/mail-merging-with-word-and-linq-to-xml-in-vb.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2007/12/06/mail-merging-with-word-and-linq-to-xml-in-vb.aspx"&gt;last bullet above&lt;/A&gt; to merge letters we were creating on the fly from a database into a single document instead of multiple documents like we’re doing. This would make it much easier for an end user to print them. That’s such an obvious thing I can’t believe I didn’t think of that! For those of you that aren’t familiar with what we did I’ll give a quick recap of that application. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Creating Word Documents with XML Literals&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;What I wanted to do is take all the Customers in the Northwind database who had some orders shipping today and send them thank you letters. To get started I created a new Word 2007 document with the letter text and some placeholder field names to indicate where I want the data:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MailMergingaSingleWordDocumentUsingXMLLi_C84D/image_6.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MailMergingaSingleWordDocumentUsingXMLLi_C84D/image_6.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MailMergingaSingleWordDocumentUsingXMLLi_C84D/image_thumb_2.png" width=687 height=385 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MailMergingaSingleWordDocumentUsingXMLLi_C84D/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Save the document (I named it Doc1.docx) and then rename the .docx extension to .zip and you can drill into the package and see a bunch of XML documents inside it. If we drill down through the zip file we'll see that the text we just typed is located in the \word\document.xml file. Copy this xml and paste it into the Visual Basic editor, it will infer it as an XDocument object, and then you can use embedded expressions to replace the placeholders. (If I’ve lost you, &lt;A href="http://blogs.msdn.com/bethmassi/archive/2007/12/06/mail-merging-with-word-and-linq-to-xml-in-vb.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2007/12/06/mail-merging-with-word-and-linq-to-xml-in-vb.aspx"&gt;read this article which explains it step-by-step&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;In order to create letters for our customers in the database, we want to end up with a collection of XDocuments with our data merged into them. I created a simple class called Letter that has two properties, CustomerID As String and Document As XDocument. Then I wrote a LINQ query to select the data and embed it into the document (I’ve omitted all the WordProcessingML for clarity, take a loot at &lt;A href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=openxmlvb&amp;amp;DownloadId=7325" target=_blank mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=openxmlvb&amp;amp;DownloadId=7325"&gt;the code sample&lt;/A&gt; for the whole listing.)&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;letters = _
&lt;SPAN style="COLOR: blue"&gt;    From &lt;/SPAN&gt;Order &lt;SPAN style="COLOR: blue"&gt;In &lt;/SPAN&gt;db.Orders _
&lt;SPAN style="COLOR: blue"&gt;    Join &lt;/SPAN&gt;Employee &lt;SPAN style="COLOR: blue"&gt;In &lt;/SPAN&gt;db.Employees _
&lt;SPAN style="COLOR: blue"&gt;        On &lt;/SPAN&gt;Order.EmployeeID &lt;SPAN style="COLOR: blue"&gt;Equals &lt;/SPAN&gt;Employee.EmployeeID _
&lt;SPAN style="COLOR: blue"&gt;    Where &lt;/SPAN&gt;Order.OrderDate &lt;SPAN style="COLOR: blue"&gt;IsNot Nothing AndAlso &lt;/SPAN&gt;_
        Order.ShippedDate &lt;SPAN style="COLOR: blue"&gt;IsNot Nothing AndAlso &lt;/SPAN&gt;_
        Order.ShippedDate.Value.Date &amp;gt;= #1/1/2007# _
&lt;SPAN style="COLOR: blue"&gt;    Let &lt;/SPAN&gt;DateOrder = Order.OrderDate.Value.ToShortDateString _
&lt;SPAN style="COLOR: blue"&gt;    Let &lt;/SPAN&gt;DateShip = Order.ShippedDate.Value.ToShortDateString _
&lt;SPAN style="COLOR: blue"&gt;    Select New &lt;/SPAN&gt;Letter &lt;SPAN style="COLOR: blue"&gt;With &lt;/SPAN&gt;{ _
        .CustomerID = Order.Customer.CustomerID, _
        .Document = &lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;xml &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;version&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;1.0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;" &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;encoding&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;utf-8&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;" &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;standalone&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;yes&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;?&amp;gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:document &lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;...&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:p &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidR&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00705CFF&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;" &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidRDefault&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00112228&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;" &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidP&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00AA2EC6&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:br&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;/&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidR&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;007A5236&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;xml:space&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;preserve&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;Dear &lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:proofErr &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;spellStart&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;/&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="BACKGROUND: #fffebf; COLOR: #555555"&gt;&amp;lt;%=&lt;/SPAN&gt; Order.Customer.ContactName &lt;SPAN style="BACKGROUND: #fffebf; COLOR: #555555"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:proofErr &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;spellEnd&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;/&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidR&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00AA2EC6&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
     &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:p&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;     &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:p &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidR&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00E04FB0&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;" &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidRDefault&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00AA2EC6&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;" &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidP&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00AA2EC6&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;xml:space&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;preserve&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;We’d like to inform you that the order you placed on &lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:proofErr &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;spellStart&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;/&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidR&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00112228&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="BACKGROUND: #fffebf; COLOR: #555555"&gt;&amp;lt;%=&lt;/SPAN&gt; DateOrder &lt;SPAN style="BACKGROUND: #fffebf; COLOR: #555555"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:proofErr &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;spellEnd&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;/&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidR&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00806521&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;xml:space&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;preserve&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;has shipped on &lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:proofErr &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;spellStart&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;/&amp;gt;
            &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidR&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00112228&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
                &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="BACKGROUND: #fffebf; COLOR: #555555"&gt;&amp;lt;%=&lt;/SPAN&gt; DateShip &lt;SPAN style="BACKGROUND: #fffebf; COLOR: #555555"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:t&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
            &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
... &lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:document&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;}&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;The query returns an IEnumerable(Of Letter) objects with the Document property set to the document.xml data for that customer. The next step involved taking the template Doc1.docx file, making a copy of it and then simply replacing the document.xml part inside the package with the one here in the Letter class for each letter. However, what I did was create separate letters for each customer. Instead we want to create one .docx file with &lt;STRONG&gt;ALL&lt;/STRONG&gt; the letter data merged inside. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Merging into a Single Word Document&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The first thing we need to do is insert a page break between all our letters. The easiest thing to do is to open back up your template Doc1.docx file in Word and insert a page break, save it, and then look at the document.xml again in the package. You should see this WordProccessingML element inserted near the end:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:p &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidR&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00622A50&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;" &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:rsidRDefault&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;00622A50&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
        &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:br &lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;w:type&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;page&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;/&amp;gt;
    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:r&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:p&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;Paste this into the query above in the document exactly where you pulled it out of the document.xml. &lt;/P&gt;
&lt;P&gt;Next we have a couple options on how to manipulate the package (docx file). I’ve shown &lt;A href="http://blogs.msdn.com/bethmassi/archive/2008/07/30/accessing-openxml-document-parts-with-the-openxml-sdk.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2008/07/30/accessing-openxml-document-parts-with-the-openxml-sdk.aspx"&gt;how to use the Open XML SDK before to manipulate documents&lt;/A&gt; but in this simple case we can use the System.IO.Packaging classes directly. This is because all we’re doing is working with text in the document. If we were working with images or embedded objects it would be easier to use the SDK. In the next post we’ll add photos of the employees on each order into the document, but for this post let’s just focus on how to merge the text. &lt;/P&gt;
&lt;P&gt;So the first thing we need to do is Import some namespaces including an XML namespace that we’re going to use:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Imports &lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #b96464"&gt;xmlns:w&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;http://schemas.openxmlformats.org/wordprocessingml/2006/main&lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Imports &lt;/SPAN&gt;System.IO
&lt;SPAN style="COLOR: blue"&gt;Imports &lt;/SPAN&gt;System.IO.Packaging&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;Next we need to set up some variables and copy the Doc1.docx template to a new file I’m calling AllLetters.docx.&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;uri &lt;SPAN style="COLOR: blue"&gt;As New &lt;/SPAN&gt;Uri(&lt;SPAN style="COLOR: #a31515"&gt;"/word/document.xml"&lt;/SPAN&gt;, UriKind.Relative)
&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;contentType = &lt;SPAN style="COLOR: #a31515"&gt;"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;sourceFile = CurDir() &amp;amp; &lt;SPAN style="COLOR: #a31515"&gt;"\Doc1.docx"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;letterDir = CurDir() &amp;amp; &lt;SPAN style="COLOR: #a31515"&gt;"\Letters\"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;My&lt;/SPAN&gt;.Computer.FileSystem.CreateDirectory(letterDir)

&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;mergeFile = letterDir &amp;amp; &lt;SPAN style="COLOR: #a31515"&gt;"AllLetters.docx"
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;My&lt;/SPAN&gt;.Computer.FileSystem.CopyFile(sourceFile, mergeFile, &lt;SPAN style="COLOR: blue"&gt;True&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;Now we can open the template package and load the main document part as an XElement:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Using &lt;/SPAN&gt;p &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;Package = Package.Open(mergeFile)

&lt;SPAN style="COLOR: green"&gt;    'get the main document part (document.xml)
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;mainPart = p.GetPart(uri)
    &lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;mainDocumentXML &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;XElement&lt;BR&gt;
&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;    &lt;SPAN style="COLOR: blue"&gt;Using &lt;/SPAN&gt;sr &lt;SPAN style="COLOR: blue"&gt;As New &lt;/SPAN&gt;StreamReader(mainPart.GetStream)
        mainDocumentXML = XElement.Load(sr)
    &lt;SPAN style="COLOR: blue"&gt;End Using&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;The next part is where it gets fun. A word document has a top element structure like this:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:document&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
    &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:body&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
       &lt;/SPAN&gt;&lt;SPAN style="COLOR: #555555"&gt;...
&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;    &amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:body&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;
&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #844646"&gt;w:document&lt;/SPAN&gt;&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;So what we need to do is grab the body of the template, replace it with the first customer’s document body we have and then append the rest of the elements inside the bodies of the rest of the documents. A word document can only have one &amp;lt;w:body&amp;gt; element for it to be legal. The way we get the &amp;lt;w:body&amp;gt; XElement from the document is using the descendants syntax with the three dot notation (…): &lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;    Dim &lt;/SPAN&gt;mainBody = mainDocumentXML...&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;&lt;/SPAN&gt;w:body&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;.First()
    &lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;i = 0

    &lt;SPAN style="COLOR: blue"&gt;For Each &lt;/SPAN&gt;letter &lt;SPAN style="COLOR: blue"&gt;In &lt;/SPAN&gt;letters
        &lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;nextBody = letter.Document...&lt;SPAN style="COLOR: #6464b9"&gt;&amp;lt;&lt;/SPAN&gt;w:body&lt;SPAN style="COLOR: #6464b9"&gt;&amp;gt;&lt;/SPAN&gt;.First()
        &lt;SPAN style="COLOR: blue"&gt;If &lt;/SPAN&gt;i = 0 &lt;SPAN style="COLOR: blue"&gt;Then
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;'Replace the first body contents in the template
            &lt;/SPAN&gt;mainBody.ReplaceNodes(nextBody.Elements())
        &lt;SPAN style="COLOR: blue"&gt;Else
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;'Append the new contents for the rest of the customers
            &lt;/SPAN&gt;mainBody.Add(nextBody.Elements())
        &lt;SPAN style="COLOR: blue"&gt;End If
        &lt;/SPAN&gt;i += 1
    &lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Now that we’ve built up the right body with all our letter data in it, we can replace the main document.xml part in the package and close it.&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: green"&gt;    'Delete the current document.xml file in the template
    &lt;/SPAN&gt;p.DeletePart(uri)
    &lt;SPAN style="COLOR: green"&gt;'Replace that part with our new merged XDocument
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;replace &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;PackagePart = p.CreatePart(uri, contentType)&lt;BR&gt;
    &lt;SPAN style="COLOR: blue"&gt;Using &lt;/SPAN&gt;sw &lt;SPAN style="COLOR: blue"&gt;As New &lt;/SPAN&gt;StreamWriter(replace.GetStream())
        mainDocumentXML.Save(sw)
        sw.Close()
    &lt;SPAN style="COLOR: blue"&gt;End Using

&lt;/SPAN&gt;    p.Close()
&lt;SPAN style="COLOR: blue"&gt;End Using&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Now when we run this, all the letters will be mail merged into the same document for easy printing:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MailMergingaSingleWordDocumentUsingXMLLi_C84D/image_4.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MailMergingaSingleWordDocumentUsingXMLLi_C84D/image_4.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MailMergingaSingleWordDocumentUsingXMLLi_C84D/image_thumb_1.png" width=703 height=253 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MailMergingaSingleWordDocumentUsingXMLLi_C84D/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;As I mentioned if we have embedded images or objects that we need to replace it gets a little trickier. In the &lt;A href="http://blogs.msdn.com/bethmassi/archive/2009/08/17/devproconnections-article-taking-advantage-of-linq-and-xml-in-microsoft-office-2007.aspx" mce_href="http://blogs.msdn.com/bethmassi/archive/2009/08/17/devproconnections-article-taking-advantage-of-linq-and-xml-in-microsoft-office-2007.aspx"&gt;DevProConnections Article&lt;/A&gt; I have an example of how to create multiple documents with embedded pictures of the employee’s photo. In the next post I’ll show you how we can use the &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en"&gt;Open XML SDK&lt;/A&gt; to create a single document with embedded pictures as well. &lt;/P&gt;
&lt;P&gt;Until then, have a look &lt;A href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=openxmlvb&amp;amp;DownloadId=7325" target=_blank mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=openxmlvb&amp;amp;DownloadId=7325"&gt;at the complete code I put up on Code Gallery&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;[UPDATE:&amp;nbsp;&lt;A href="http://blogs.msdn.com/bethmassi/archive/2009/09/24/merging-text-photos-into-a-word-document-using-open-xml-sdk.aspx" mce_href="http://blogs.msdn.com/bethmassi/archive/2009/09/24/merging-text-photos-into-a-word-document-using-open-xml-sdk.aspx"&gt;Merging Text &lt;STRONG&gt;&amp;amp; Photos &lt;/STRONG&gt;into a Word Document using Open XML SDK&lt;/A&gt;]&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9898711" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Office/default.aspx">Office</category></item><item><title>DevProConnections Article: Taking Advantage of LINQ and XML in Microsoft Office 2007</title><link>http://blogs.msdn.com/bethmassi/archive/2009/08/17/devproconnections-article-taking-advantage-of-linq-and-xml-in-microsoft-office-2007.aspx</link><pubDate>Mon, 17 Aug 2009 20:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9879123</guid><dc:creator>Beth Massi</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9879123.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9879123</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9879123</wfw:comment><description>&lt;p&gt;This month I have an article on DevProConnections:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://www.devproconnections.com/tabId/180/itemId/4575/Taking-Advantage-of-LINQ-and-XML-in-Microsoft-Offi.aspx" target="_blank"&gt;Taking Advantage of LINQ and XML in Microsoft Office 2007&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In this article, I talk about how a lot of applications that need to take advantage of Microsoft Office can do so without going through COM. Many programs that need to process documents often require manipulation of the file formats directly and doing that through the Office component object model won’t scale very well. It also requires that Microsoft Office be installed to run. A better route in a lot of these cases is to use the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" target="_blank"&gt;Open XML SDK&lt;/a&gt;. With the release of Office 2007, Word documents, Excel spreadsheets and PowerPoint presentations are based on an open standard for packaging XML files called Open XML. Using Visual Basic’s powerful and simple implementation of LINQ to XML you can work with these new document formats much easier than ever before.&lt;/p&gt;  &lt;p&gt;I show a couple practical examples of reading data from Word documents and updating a database as well as reading data from a database to create Word documents – all without COM. No Office applications need to be installed in order to read and write to these formats directly.&amp;#160; &lt;/p&gt;  &lt;p&gt;This article is based on the two episodes I did on DnrTV:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/04/07/dnrtv-showing-off-the-open-xml-sdk-and-linq.aspx"&gt;dnrTV: Showing off the Open XML SDK and LINQ&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/04/20/dnrtv-more-fun-with-office-and-xml-literals.aspx"&gt;dnrTV: More Fun with Office and XML Literals&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;[UPDATE: Here's code samples (also includes a presentation pptx)] &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/openxmlvb"&gt;Working with Open XML in Visual Basic&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;More resources:&lt;/p&gt;  &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en"&gt;Open XML Format SDK 2.0&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/office/bb265236.aspx"&gt;Open XML Resource Center&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en"&gt;Microsoft Visual Studio Tools for the Office System Power Tools v1.0.0.0&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://www.codeplex.com/dbe"&gt;Word 2007 Content Control Toolkit &lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href="http://msdn.com/vsto"&gt;VSTO Developer Center&lt;/a&gt; &lt;/li&gt;  &lt;li&gt;&lt;a href="http://msdn.com/vbasic"&gt;Visual Basic Developer Center&lt;/a&gt;     &lt;p&gt;Enjoy!&lt;/p&gt;    &lt;p&gt;&lt;/p&gt; &lt;/li&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9879123" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Office/default.aspx">Office</category></item><item><title>Using Windows Presentation Foundation in Office Clients</title><link>http://blogs.msdn.com/bethmassi/archive/2009/08/10/using-windows-presentation-foundation-in-office-clients.aspx</link><pubDate>Tue, 11 Aug 2009 03:31:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9863656</guid><dc:creator>Beth Massi</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9863656.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9863656</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9863656</wfw:comment><description>&lt;p&gt;&lt;img style="display: inline; margin: 0px 10px 10px 0px" src="http://www.sdn.nl/Portals/0/Upload/Images/2009/Website/VP101.png" align="left" /&gt; I was cleaning up my desk today and in the piles of mail and gobs of paper I found the &lt;a href="http://www.sdn.nl/SDN/Magazine/tabid/66/articleType/ArticleView/articleId/2870/SDN-Magazine-101-Women-In-Technology-is-uit.aspx" target="_blank"&gt;SDN Magazine “Women in Technology” issue 101&lt;/a&gt; that featured an article I wrote that was released in print back in May. Well, I just noticed today that near the end of June they made most of the articles available online, including mine. :-)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.sdn.nl/SDN/Artikelen/tabid/58/agentType/View/PropertyID/2982/Default.aspx"&gt;&lt;strong&gt;Using Windows Presentation Foundation and Line-of-Business Data in Microsoft Office Clients&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this article I talk about how to expose Line-of-Business data via ADO.NET Data Services to an Excel client using WPF. Office solutions you build with Visual Studio are designed to work with Windows Forms controls but you can also use WPF controls in your solutions as well. Any UI element that can host Windows Forms controls in an Office solution (VSTO) can also host WPF controls using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.elementhost.aspx" target="_blank"&gt;Winforms ElementHost&lt;/a&gt; as a container. &lt;/p&gt;  &lt;p&gt;Using WPF controls in Office allows you to think out of the box and provide world-class data visualizations that are not possible with Windows Forms controls. And you can do it easily in an instantly familiar end-user application like those in the Office family. But what if you don’t have any fancy data visualizations? Even the simplest controls that display data are often better off as WPF controls in Office applications because they better match the UI styles used in the latest versions of Office. Using WPF can make your add-ins look built into the Office applications themselves, providing a better user experience.&lt;/p&gt;  &lt;p&gt;This article describes one piece of the Northwind Office Business Application (OBA) we created in the beginning of the year so if you’re interested in OBA development with Outlook, Word, Excel and Sharepoint I’d suggest reading these as well:&lt;/p&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/02/03/oba-part-1-exposing-line-of-business-data.aspx"&gt;OBA Part 1 - Exposing Line-of-Business Data&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/02/07/oba-part-2-building-and-outlook-client-against-lob-data.aspx"&gt;OBA Part 2 - Building and Outlook Client against LOB Data&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/02/12/oba-part-3-storing-and-reading-data-in-word-documents.aspx"&gt;OBA Part 3 - Storing and Reading Data in Word Documents&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/03/08/oba-part-4-building-an-excel-client-against-lob-data.aspx"&gt;OBA Part 4 - Building an Excel Client against LOB Data&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/04/21/oba-part-5-building-the-sharepoint-2007-workflow.aspx"&gt;OBA Part 5 - Building the SharePoint 2007 Workflow&lt;/a&gt;&lt;/li&gt;  &lt;p&gt;The full sample application, built with Visual Studio 2008, is here: &lt;a title="http://code.msdn.microsoft.com/OBANorthwind" href="http://code.msdn.microsoft.com/OBANorthwind"&gt;http://code.msdn.microsoft.com/OBANorthwind&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Of course, the rest of the magazine is pack full of awesome articles from very well known women in technology (scroll to the bottom of &lt;a href="http://www.sdn.nl/SDN/Magazine/tabid/66/articleType/ArticleView/articleId/2870/SDN-Magazine-101-Women-In-Technology-is-uit.aspx" target="_blank"&gt;this page&lt;/a&gt; for the whole list). I’m honored to be featured with them in this issue. Thanks again to &lt;a href="http://information-worker.org/aboutus.aspx" target="_blank"&gt;Marianne van Wanrooij&lt;/a&gt; and the folks at &lt;a href="http://www.sdn.nl" target="_blank"&gt;SDN&lt;/a&gt; for putting this together and I’ll see you &lt;a href="http://www.sdc.nl/" target="_blank"&gt;in October at the SDN Conference&lt;/a&gt;!&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9863656" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/ADO.NET+Data+Services/default.aspx">ADO.NET Data Services</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VSTO/default.aspx">VSTO</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/OBA/default.aspx">OBA</category></item><item><title>Good Times at DevTeach, Vancouver</title><link>http://blogs.msdn.com/bethmassi/archive/2009/06/19/good-times-at-devteach-vancouver.aspx</link><pubDate>Sat, 20 Jun 2009 03:24:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9792450</guid><dc:creator>Beth Massi</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9792450.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9792450</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9792450</wfw:comment><description>&lt;p&gt;Last week I spoke at &lt;a href="http://www.devteach.com/" target="_blank"&gt;DevTeach&lt;/a&gt; in Vancouver which was held at the beautiful Four Seasons in downtown. I love this Canadian conference because the attendees are great – super friendly and social, and ask a lot of great questions. I mostly interacted with folks building applications for the government or working as consultants and wanting to freshen up their .NET skills. It was also nice to see a good number of VB developers here. I gave three talks and ended up in the top 3 speakers overall which was great :-). &lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;strong&gt;Future Directions for Visual Basic and C#&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Before the conference I did a joint user’s group talk and about 120 people showed up to see “&lt;em&gt;Future Directions for Visual Basic and C#&lt;/em&gt;” which has also been delivered before at PDC and TechEd by folks on the Language Team. I did a flavor of &lt;a href="http://services.social.microsoft.com/feeds/FeedItem?feedId=c1cf0fd1-95b7-42b9-a6fa-8e48d55c5411&amp;amp;itemId=9db6fd68-220a-4932-8ec0-e4c807499d84&amp;amp;title=TechEd%3a+Future+Directions+for+Visual+Basic&amp;amp;uri=http%3a%2f%2fwww.msteched.com%2fonline%2fview.aspx%3ftid%3d1d3d650b-a6b3-4c98-9240-571866969b89&amp;amp;k=UV75hhA0OqzauUokJoycPxZSxiny%2b1vx2oDW5QVb5%2fw%3d" target="_blank"&gt;Jonathan Aneja’s TechEd talk&lt;/a&gt; but I also included new C# features which I have to say are a welcome relief to me personally. Unfortunately my VM was misbehaving so badly that Visual Studio was running at a snail’s pace. But I joked around and got through it ending up with some good comments and questions. I did the talk again at the conference and my VM was just fine – go figure. As a bonus for the conference attendees I also included a VB REPL demo and it was a hit. Check out &lt;a href="http://services.social.microsoft.com/feeds/FeedItem?feedId=c1cf0fd1-95b7-42b9-a6fa-8e48d55c5411&amp;amp;itemId=9db6fd68-220a-4932-8ec0-e4c807499d84&amp;amp;title=TechEd%3a+Future+Directions+for+Visual+Basic&amp;amp;uri=http%3a%2f%2fwww.msteched.com%2fonline%2fview.aspx%3ftid%3d1d3d650b-a6b3-4c98-9240-571866969b89&amp;amp;k=UV75hhA0OqzauUokJoycPxZSxiny%2b1vx2oDW5QVb5%2fw%3d" target="_blank"&gt;John’s TechEd recording&lt;/a&gt; for variations of the VB demos that I showed. &lt;/p&gt; &lt;p&gt;Most interesting was the group that attended the talk. It was almost a 50/50 split between VB and C# devs in the room with some cross-over (doing both). I even had 3 C++ programmers attend. I started out with all the new VB features, then showed all the new C# features and then finished up with the new features in both. I had a lot of fun with the session, jabbing at both languages here and there and poking fun in places where one was catching up to the other and vice versa. Here’s the breakdown of new stuff in each language:&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2" width="400" border="1"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;strong&gt;Feature &lt;/strong&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;strong&gt;VB10 &lt;/strong&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;strong&gt;C#4&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;Auto-implemented Properties &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #7878de"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y&lt;/font&gt;&lt;/strong&gt; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;Collection Initializers &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #7878de"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y&lt;/font&gt;&lt;/strong&gt; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;Multiline &amp;amp; Statement Lambdas &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #7878de"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y&lt;/font&gt;&lt;/strong&gt; &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;Implicit Line Continuation &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;N/A&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;Named/Optional Parameters &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #7878de"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y&lt;/font&gt;&lt;/strong&gt; &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;Late binding support (dynamic) &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #7878de"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y&lt;/font&gt;&lt;/strong&gt; &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;Omit ref on COM calls &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #7878de"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y&lt;/font&gt;&lt;/strong&gt; &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;DLR Integration &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;Generic Variance &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="192"&gt;&lt;span style="color: black"&gt;PIA deployment not needed &lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="106"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt; &lt;td valign="top" width="101"&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y &lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;pre class="code"&gt;&lt;span style="color: #7878de"&gt;&lt;strong&gt;&lt;font size="3"&gt;Y = Already exists in VB9/C#3&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: #00b050"&gt;&lt;strong&gt;&lt;font size="3"&gt;&lt;br&gt;Y = New in VB10/C#4&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;&lt;/pre&gt;&lt;/span&gt;
&lt;p&gt;Check out the &lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd238515.aspx" target="_blank"&gt;Visual Studio 2010 Language samples&lt;/a&gt; and language &lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx" target="_blank"&gt;walkthroughs&lt;/a&gt; for details on each of these features.&lt;/p&gt;
&lt;p&gt;The C# crowd seemed in particular to like the Named &amp;amp; Optional parameter support commenting that “It’s useful because it saves me writing code”. I actually showed all of the C# 4 features in one method that demonstrated COM interop with Office lifted from &lt;a href="http://msdn.microsoft.com/en-us/library/dd867746.aspx" target="_blank"&gt;this walkthrough&lt;/a&gt;. The VB crowd was particularly pleased to see no more underscores and auto-implemented properties. And those that commented in the session were pleased to see the language parity. I’m just glad I didn’t get any rotten tomatoes thrown at me from either side. :-)&lt;/p&gt;
&lt;p&gt;Here’s some more resources to check out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" target="_blank"&gt;Visual Studio 2010 and .NET Framework 4 Beta 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/dd819153.aspx"&gt;Visual Basic 2010 Resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/vcsharp/dd819407.aspx"&gt;Visual C# 2010 Resources&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/vbteam " target="_blank"&gt;VB Team Blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/csharpfaq/" target="_blank"&gt;C# FAQ Blog&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Data Sources and Data Binding with WPF&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I’ve done this talk &lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/12/08/back-from-devteach-montreal.aspx" target="_blank"&gt;many times before&lt;/a&gt; and it’s always a lot of fun. I've been &lt;a href="http://blogs.msdn.com/bethmassi/archive/tags/WPF/default.aspx"&gt;blogging&lt;/a&gt; on data binding in WPF as well as doing &lt;a href="http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx#wpfdata"&gt;How Do I videos&lt;/a&gt; for a while now. This talk takes WPF data binding from a Winforms developer perspective and I try to demonstrate that investments made in your Winforms data sources can be used in WPF. The crowd seemed relieved ;-). I also showed the drag-drop data binding in Visual Studio 2010 building a form similar to what &lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/11/26/channel-9-interview-wpf-drag-drop-data-binding-in-visual-studio-2010.aspx"&gt;Milind showed in this Channel 9 interview&lt;/a&gt;. The team has also been blogging heavily about &lt;a href="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx" target="_blank"&gt;WPF data binding in VS2010&lt;/a&gt; on the &lt;a href="http://blogs.msdn.com/vsdata/" target="_blank"&gt;VS Data blog&lt;/a&gt; so check it out. &lt;/p&gt;
&lt;p&gt;Here’s some more resources to check out:&lt;/p&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/09/24/data-sources-and-data-binding-in-wpf-talk-in-redmond.aspx"&gt;Data Sources and Data Binding in WPF &lt;/a&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx#wpfdata"&gt;WPF Forms over Data Videos&lt;/a&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/11/26/channel-9-interview-wpf-drag-drop-data-binding-in-visual-studio-2010.aspx"&gt;Channel 9 Interview: WPF Drag-Drop Data Binding in Visual Studio 2010&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/vsdata/archive/tags/WPF/default.aspx" target="_blank"&gt;VS Data Team Blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" target="_blank"&gt;Visual Studio 2010 and .NET Framework 4 Beta 1&lt;/a&gt;&lt;/li&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Conquering XML with LINQ in Visual Basic 9&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This has got to be one of my most favorite talks of all time. I've written a lot &lt;a href="http://blogs.msdn.com/bethmassi/archive/tags/XML/LINQ/Article/default.aspx"&gt;on this topic&lt;/a&gt;. I have been doing this one for a couple years now and what’s great about it is that it never gets old. It’s amazing how many folks are still not aware of XML Literals in VB. Only about 10% of attendees had used them before so I started with the basics and worked my way up into the demos. This talk scored very high for me and I think it’s because I show a lot of practical examples of using XML Literals and LINQ to XML. I didn’t show any betas or unreleased bits either and I think folks appreciated that they could go home and get working with it right away. &lt;/p&gt;
&lt;p&gt;I got through all the demos and showed a good amount of &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en"&gt;Open XML SDK&lt;/a&gt; to manipulate Office 2007 documents. I also showed off the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en"&gt;VSTO Power tools&lt;/a&gt; a bit for viewing the Open XML packages. Amongst the many demos we went through, we built a letter generator from scratch &lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/07/30/accessing-openxml-document-parts-with-the-openxml-sdk.aspx"&gt;like I've shown before here&lt;/a&gt;. I also did my famous &lt;a href="http://blogs.msdn.com/bethmassi/archive/2007/12/03/northwind-meets-virtual-earth-generate-ve-maps-with-linq.aspx"&gt;Virtual Earth demo&lt;/a&gt; that people always enjoy.&lt;/p&gt;
&lt;p&gt;Here’s some more resources to check out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/XML/default.aspx" target="_blank"&gt;My LINQ to XML blog posts &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.code-magazine.com/article.aspx?quickid=0807061" target="_blank"&gt;Sharpening Your Axis with Visual Basic 9&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc947916.aspx" target="_blank"&gt;Dynamic Data Entry With XML Literals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032374409&amp;amp;EventCategory=5&amp;amp;culture=en-US&amp;amp;CountryCode=US" target="_blank"&gt;Webcast: Working with XML in Visual Basic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/vbteam " target="_blank"&gt;VB Team Blog&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;I also attended a few sessions myself on MVVM and Silverlight so you may see more of that cranking out of this blog at some point. ;-) I look forward to the next DevTeach! &lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9792450" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Speaking/default.aspx">Speaking</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2010/default.aspx">VS2010</category></item><item><title>dnrTV: More Fun with Office and XML Literals</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/20/dnrtv-more-fun-with-office-and-xml-literals.aspx</link><pubDate>Mon, 20 Apr 2009 22:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9557170</guid><dc:creator>Beth Massi</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9557170.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9557170</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9557170</wfw:comment><description>&lt;P&gt;Yesterday Carl posted &lt;A href="http://www.dnrtv.com/default.aspx?showNum=138" mce_href="http://www.dnrtv.com/default.aspx?showNum=138"&gt;another dnrTV show&lt;/A&gt; with yours truly. This is a follow up from the &lt;A href="http://www.dnrtv.com/default.aspx?showNum=137" mce_href="http://www.dnrtv.com/default.aspx?showNum=137"&gt;last show&lt;/A&gt; where I went over the Open XML SDK and LINQ to XML in order to manipulate and query Office documents. Last show focused on CustomXML parts and Word content controls. In this show I demonstrate how to create Word and Excel docs from database data using XML Literals. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.dnrtv.com/default.aspx?showNum=137" mce_href="http://www.dnrtv.com/default.aspx?showNum=137"&gt;dnrTV Show #137: Beth Massi on the Open XML SDK&lt;/A&gt; &lt;BR&gt;&lt;A href="http://www.dnrtv.com/default.aspx?showNum=138" mce_href="http://www.dnrtv.com/default.aspx?showNum=138"&gt;&lt;STRONG&gt;dnrTV Show #138: Beth Massi on Open XML and Office&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here are some links to check out from the shows:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en"&gt;Open XML Format SDK 2.0&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en"&gt;Microsoft Visual Studio Tools for the Office System Power Tools v1.0.0.0&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.codeplex.com/dbe" mce_href="http://www.codeplex.com/dbe"&gt;Word 2007 Content Control Toolkit &lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.com/vsto" mce_href="http://msdn.com/vsto"&gt;VSTO Developer Center&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.com/vbasic" mce_href="http://msdn.com/vbasic"&gt;Visual Basic Developer Center&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/office/bb265236.aspx" mce_href="http://msdn.microsoft.com/en-us/office/bb265236.aspx"&gt;Open XML Resource Center&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;And here's the &lt;A class="" href="http://code.msdn.microsoft.com/openxmlvb" target=_blank mce_href="http://code.msdn.microsoft.com/openxmlvb"&gt;source&amp;nbsp;code for the demos&lt;/A&gt; I showed. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9557170" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Speaking/default.aspx">Speaking</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Videos/default.aspx">Videos</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>dnrTV: Showing off the Open XML SDK and LINQ</title><link>http://blogs.msdn.com/bethmassi/archive/2009/04/07/dnrtv-showing-off-the-open-xml-sdk-and-linq.aspx</link><pubDate>Wed, 08 Apr 2009 01:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9536792</guid><dc:creator>Beth Massi</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9536792.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9536792</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9536792</wfw:comment><description>&lt;P&gt;Yesterday &lt;A href="http://www.intellectualhedonism.com/" target=_blank mce_href="http://www.intellectualhedonism.com/"&gt;Carl&lt;/A&gt; posted another &lt;A href="http://www.dnrtv.com/default.aspx?showNum=137" target=_blank mce_href="http://www.dnrtv.com/default.aspx?showNum=137"&gt;dnrTV show with yours truly&lt;/A&gt;. This time I’m talking about the &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en"&gt;Open XML SDK&lt;/A&gt;, something that I’ve &lt;A href="http://blogs.msdn.com/bethmassi/archive/tags/XML/Office/default.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/tags/XML/Office/default.aspx"&gt;written and spoken about many times&lt;/A&gt;. &lt;A href="http://www.dnrtv.com/default.aspx?showNum=137" target=_blank mce_href="http://www.dnrtv.com/default.aspx?showNum=137"&gt;In this episode&lt;/A&gt; I show how to use Word 2007 content controls and map them to custom XML parts so that you can query structured data from unstructured documents using Visual Basic’s LINQ to XML. What’s really cool about the Open XML format is that you don’t need Office installed at all – no COM Interop needed. You’re working with the file formats directly. And it’s super simple using VB’s XML literals and LINQ with the SDK.&lt;/P&gt;
&lt;P&gt;Unfortunately I didn’t have a lot of time when I did the show with Carl and I couldn’t finish my demos. So this morning I filmed another quick episode that shows how to create documents from database data directly, so keep on the lookout for the follow up show :-).&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.dnrtv.com/default.aspx?showNum=137" target=_blank mce_href="http://www.dnrtv.com/default.aspx?showNum=137"&gt;&lt;STRONG&gt;dnrTV Show: Beth Massi on the Open XML SDK&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;And here are the links from the show:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en"&gt;Open XML Format SDK 2.0&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en"&gt;Microsoft Visual Studio Tools for the Office System Power Tools v1.0.0.0&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.codeplex.com/dbe" mce_href="http://www.codeplex.com/dbe"&gt;Word 2007 Content Control Toolkit &lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.com/vsto" mce_href="http://msdn.com/vsto"&gt;VSTO Developer Center&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;[UPDATE: Here's code samples (also includes a presentation pptx)]&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A class="" id=ctl00_ctl00_WideContent_ProjectTitleControl1_ProjectTitleLink href="http://code.msdn.microsoft.com/openxmlvb" target=_blank s_oid="http://code.msdn.microsoft.com/openxmlvb" s_oidt="0" mce_href="http://code.msdn.microsoft.com/openxmlvb"&gt;&lt;SPAN id=ctl00_ctl00_WideContent_ProjectTitleControl1_TitleLabel&gt;&lt;FONT color=#3e62a6&gt;Working with Open XML in Visual Basic&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9536792" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>Channel 9 Interview: ASP.NET MVC using Visual Basic XML Literals</title><link>http://blogs.msdn.com/bethmassi/archive/2009/02/16/channel-9-interview-asp-net-mvc-using-visual-basic-xml-literals.aspx</link><pubDate>Mon, 16 Feb 2009 20:20:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9426144</guid><dc:creator>Beth Massi</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9426144.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9426144</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9426144</wfw:comment><description>&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/funkyonex/ASPNET-MVC-using-Visual-Basic-XML-Literals/" target="_blank"&gt;&lt;strong&gt;I just posted an interview on Channel 9&lt;/strong&gt;&lt;/a&gt; with Dmitry Robsman, the Product Unit Manager for ASP.NET. &lt;a href="http://channel9.msdn.com/posts/funkyonex/ASPNET-MVC-using-Visual-Basic-XML-Literals/" target="_blank"&gt;In this interview&lt;/a&gt; he shows us how he implemented ASP.NET MVC views using Visual Basic's XML Literals instead of .aspx pages. Dmitry shows us how this makes coding the views much cleaner using standard OOP principals. He also makes some very interesting observations about DSLs and Visual Basic XML literals. You can download the code Dmitry shows in the interview &lt;a href="http://blogs.msdn.com/dmitryr/archive/2008/12/29/asp-net-mvc-view-engine-using-vb-net-xml-literals.aspx"&gt;from his blog here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9426144" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Videos/default.aspx">Videos</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Channel9/default.aspx">Channel9</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category></item><item><title>OBA Part 3 - Storing and Reading Data in Word Documents</title><link>http://blogs.msdn.com/bethmassi/archive/2009/02/12/oba-part-3-storing-and-reading-data-in-word-documents.aspx</link><pubDate>Fri, 13 Feb 2009 04:55:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9416665</guid><dc:creator>Beth Massi</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9416665.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9416665</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9416665</wfw:comment><description>&lt;p&gt;In my last few posts we've been building a simple Office Business Application (OBA) for the new Northwind Traders. If you missed them:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/02/03/oba-part-1-exposing-line-of-business-data.aspx" target="_blank"&gt;OBA Part 1 - Exposing Line-of-Business Data&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/02/07/oba-part-2-building-and-outlook-client-against-lob-data.aspx" target="_blank"&gt;OBA Part 2 - Building and Outlook Client against LOB Data&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In this post I'm going to talk about how we can create a purchase order in Word 2007 that contains data about the items being purchased and how we can query that data and place it into our database. We'll use this code as a basis for our SharePoint Workflow which we will build out in the next post. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/WordOBADiagram_2.jpg"&gt;&lt;img style="margin: 0px 10px 0px 0px" height="375" alt="WordOBADiagram" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/WordOBADiagram_thumb.jpg" width="389" align="left" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you recall &lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/02/02/building-an-office-business-application-for-techready-8.aspx" target="_blank"&gt;our architecture diagram of our Northwind Traders OBA&lt;/a&gt; involved our Sales Reps submitting purchase orders as Word 2007 documents up to SharePoint which kicked off a workflow to parse the document and update the database with the order data through our data service.&lt;/p&gt;  &lt;p&gt;This allows us to store the unstructured document on SharePoint and the structured order data in our database. &lt;/p&gt;  &lt;p&gt;However before we build out the SharePoint Workflow we need a clean way to store and then retrieve the structured order data inside the Word 2007 document. Since Word 2007 documents are Open XML we can use the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" target="_blank"&gt;Open XML SDK&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/bb384460.aspx" target="_blank"&gt;LINQ to XML&lt;/a&gt; to easily parse the document. (I've talked about how to &lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/07/30/accessing-openxml-document-parts-with-the-openxml-sdk.aspx" target="_blank"&gt;manipulate documents with Open XML SDK before here&lt;/a&gt;.) &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Content Controls&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;One way to store data in an Word 2007 document is by using content controls. These allow you to define specific data areas/fields in the document which are then bound to XML that is placed inside the document. When users enter data into these areas of the document the data is stored as a CustomXML Part inside the document. You can use &lt;a href="http://msdn.microsoft.com/en-us/library/bb398244.aspx" target="_blank"&gt;Visual Studio to create content controls and map them to XML&lt;/a&gt; or you can use Word itself. There's also a nifty tool called the &lt;a href="http://www.codeplex.com/dbe" target="_blank"&gt;Word 2007 Content Control Toolkit&lt;/a&gt; that makes the mapping more visual. I'd also highly recommend installing the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" target="_blank"&gt;VSTO Power Tools&lt;/a&gt; as well which includes &lt;a href="http://blogs.msdn.com/bethmassi/archive/2008/07/29/handy-visual-studio-add-in-to-view-office-2007-files.aspx" target="_blank"&gt;a VS Add-In for manipulating Open XML documents&lt;/a&gt;. This allows you to look inside the document easily to inspect all the parts directly within Visual Studio.&lt;/p&gt;  &lt;p&gt;So the first thing to do is to create a purchase order template and lay out the content controls on the document. We'll create something very simple using Microsoft Word 2007. On the Developer tab you will see the Controls section. There you can choose which types of controls to lay out on the document. Click the properties button to assign a friendly title and tag to the control. Here I've laid out the minimum information we'll need to submit an order to the system:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc1_2.jpg"&gt;&lt;img height="438" alt="wordcc1" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc1_thumb.jpg" width="672" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Users can write anything else around the content controls but the system only cares about capturing the data we've specified. This gives us the ability to store structured and unstructured data completely inside the .docx file. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Creating and Mapping the XML&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now we are ready to map the values of the content controls to some custom XML. The XML document for our order looks like this. (Note that there are 10 &amp;lt;OrderDetail&amp;gt; elements I just snipped them for brevity):&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;OrderEntry &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;urn:microsoft:examples:oba&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;CustomerID &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;OrderDate &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Shipper &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;OrderDetails&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;OrderDetail&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ProductName &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Quantity &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;OrderDetail&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;span style="color: blue"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;OrderDetail&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;...&lt;/span&gt;&lt;span style="color: blue"&gt;
  &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;OrderDetails&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;OrderEntry&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Now open up the &lt;a href="http://www.codeplex.com/dbe" target="_blank"&gt;Word 2007 Content Control Toolkit&lt;/a&gt; an open the OrderEntryTemplate.docx. Under Actions select &amp;quot;Create a new Custom XML Part&amp;quot;, switch to edit view, and then paste in the XML:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc2_2.jpg"&gt;&lt;img height="491" alt="wordcc2" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc2_thumb.jpg" width="594" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Next switch to Bind View and then drag the elements onto the content controls on the left. Make sure you select the element first and then drag it.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc3_2.jpg"&gt;&lt;img height="352" alt="wordcc3" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc3_thumb.jpg" width="629" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Once you're done, save the document and then you can open it in Visual Studio if you've loaded the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&amp;amp;displaylang=en" target="_blank"&gt;VSTO Power Tools&lt;/a&gt;. This will show the Open XML parts of the document and you can expand the customXml folder and see that our XML has been added to the document. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc4_2.jpg"&gt;&lt;img height="379" alt="wordcc4" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc4_thumb.jpg" width="660" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you back into Word and fill out the content controls and then view the document in Visual Studio again, you will see that the item1.xml custom XML part will contain the data we entered. &lt;/p&gt;

&lt;p&gt;Now that we have a purchase order template we can give this to our sales reps who can collaborate with our high volume customers via email to fill it out. They can then submit the purchase orders to a SharePoint list that can run a workflow to extract the order data and update the database through the data service. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the Open XML SDK to Retrieve the Order Data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The easiest way to programmatically manipulate Office 2007 Open XML documents is by using the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" target="_blank"&gt;Open XML SDK&lt;/a&gt;. Once you install it you can then Add Reference to the DocumentFormat.OpenXML assembly. In order to use LINQ to XML you'll also need a reference to System.Core and System.Xml.Linq. These are imported automatically when you create a new project in Visual Studio 2008. You'll also need to &lt;a href="http://msdn.microsoft.com/en-us/library/cc668183.aspx" target="_blank"&gt;add a Service Reference to the ADO.NET Data Service&lt;/a&gt; like &lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/01/09/using-ado-net-data-services.aspx" target="_blank"&gt;I've shown before&lt;/a&gt;. So let's start simple and just create a console application for now called NorthwindOrderDocParser. Later we'll talk about moving this to a SharePoint workflow. &lt;/p&gt;

&lt;p&gt;Before we start parsing the document let's create a couple simple classes that store the data we're extracting from our document.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;
&lt;/span&gt;&lt;span style="color: green"&gt;''' These classes represents the order data that is inside the Word Document. 
''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;
&lt;/span&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;Public Class &lt;/span&gt;DocumentOrderData

    &lt;span style="color: blue"&gt;Sub New&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;customerID &lt;span style="color: blue"&gt;As String&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;orderDate &lt;span style="color: blue"&gt;As Date&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;shipperName &lt;span style="color: blue"&gt;As String&lt;/span&gt;)
        _CustomerID = customerID
        _OrderDate = orderDate
        _Shipper = shipperName
    &lt;span style="color: blue"&gt;End Sub

    Private &lt;/span&gt;_CustomerID &lt;span style="color: blue"&gt;As String
    Public Property &lt;/span&gt;CustomerID() &lt;span style="color: blue"&gt;As String
        Get
            Return &lt;/span&gt;_CustomerID
        &lt;span style="color: blue"&gt;End Get
        Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="color: blue"&gt;As String&lt;/span&gt;)
            _CustomerID = value
        &lt;span style="color: blue"&gt;End Set
    End Property

    Private &lt;/span&gt;_OrderDate &lt;span style="color: blue"&gt;As Date
    Public Property &lt;/span&gt;OrderDate() &lt;span style="color: blue"&gt;As Date
        Get
            Return &lt;/span&gt;_OrderDate
        &lt;span style="color: blue"&gt;End Get
        Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="color: blue"&gt;As Date&lt;/span&gt;)
            _OrderDate = value
        &lt;span style="color: blue"&gt;End Set
    End Property

    Private &lt;/span&gt;_Shipper &lt;span style="color: blue"&gt;As String
    Public Property &lt;/span&gt;Shipper() &lt;span style="color: blue"&gt;As String
        Get
            Return &lt;/span&gt;_Shipper
        &lt;span style="color: blue"&gt;End Get
        Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="color: blue"&gt;As String&lt;/span&gt;)
            &lt;span style="color: blue"&gt;If &lt;/span&gt;value &lt;span style="color: blue"&gt;Is Nothing OrElse &lt;/span&gt;value.Trim = &lt;span style="color: #a31515"&gt;&amp;quot;&amp;quot; &lt;/span&gt;&lt;span style="color: blue"&gt;Then
                &lt;/span&gt;value = &lt;span style="color: #a31515"&gt;&amp;quot;Speedy Express&amp;quot;
            &lt;/span&gt;&lt;span style="color: blue"&gt;End If
            &lt;/span&gt;_Shipper = value
        &lt;span style="color: blue"&gt;End Set
    End Property

    Private &lt;/span&gt;_details &lt;span style="color: blue"&gt;As New &lt;/span&gt;List(&lt;span style="color: blue"&gt;Of &lt;/span&gt;Detail)
    &lt;span style="color: blue"&gt;Public ReadOnly Property &lt;/span&gt;Details() &lt;span style="color: blue"&gt;As &lt;/span&gt;List(&lt;span style="color: blue"&gt;Of &lt;/span&gt;Detail)
        &lt;span style="color: blue"&gt;Get
            Return &lt;/span&gt;_details
        &lt;span style="color: blue"&gt;End Get
    End Property

    Public Class &lt;/span&gt;Detail
        &lt;span style="color: blue"&gt;Sub New&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;productName &lt;span style="color: blue"&gt;As String&lt;/span&gt;, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;quantity &lt;span style="color: blue"&gt;As Short&lt;/span&gt;)
            _ProductName = productName
            _Quantity = quantity
        &lt;span style="color: blue"&gt;End Sub

        Private &lt;/span&gt;_ProductName &lt;span style="color: blue"&gt;As String
        Public Property &lt;/span&gt;ProductName() &lt;span style="color: blue"&gt;As String
            Get
                Return &lt;/span&gt;_ProductName
            &lt;span style="color: blue"&gt;End Get
            Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="color: blue"&gt;As String&lt;/span&gt;)
                _ProductName = value
            &lt;span style="color: blue"&gt;End Set
        End Property

        Private &lt;/span&gt;_Quantity &lt;span style="color: blue"&gt;As Short
        Public Property &lt;/span&gt;Quantity() &lt;span style="color: blue"&gt;As Short
            Get
                Return &lt;/span&gt;_Quantity
            &lt;span style="color: blue"&gt;End Get
            Set&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;value &lt;span style="color: blue"&gt;As Short&lt;/span&gt;)
                _Quantity = value
            &lt;span style="color: blue"&gt;End Set
        End Property
    End Class
End Class&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Next, let's add a schema for the OrderEntry XML data that is contained in the document. This will give us &lt;a href="http://msdn.microsoft.com/en-us/library/bb531325.aspx" target="_blank"&gt;IntelliSense on our XML&lt;/a&gt; when we're using LINQ to XML. We can just open the document in Visual Studio like before and copy the OrderEntry XML data into the clipboard. Then we can Add a new &lt;a href="http://msdn.microsoft.com/en-us/library/cc442691.aspx" target="_blank"&gt;XML to Schema&lt;/a&gt; Item and paste into the Wizard's dialog box. This will infer the schema and place the XSD file into the project automatically for us. Notice that I specified a namespace on our OrderEntry XML data. We now can import this namespace into our main program along with a few other .NET namespaces we'll need:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: green"&gt;'Reference to our data service and data entities:
&lt;/span&gt;&lt;span style="color: blue"&gt;Imports &lt;/span&gt;NorthwindOrderDocParser.NorthwindService
&lt;span style="color: green"&gt;'Open XML SDK:
&lt;/span&gt;&lt;span style="color: blue"&gt;Imports &lt;/span&gt;DocumentFormat.OpenXml.Packaging
&lt;span style="color: blue"&gt;Imports &lt;/span&gt;System.IO
&lt;span style="color: green"&gt;'Default XML Namespace:
&lt;/span&gt;&lt;span style="color: blue"&gt;Imports &lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #b96464"&gt;xmlns&lt;/span&gt;&lt;span style="color: #6464b9"&gt;=&lt;/span&gt;&lt;span style="color: #555555"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #6464b9"&gt;urn:microsoft:examples:oba&lt;/span&gt;&lt;span style="color: #555555"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;We are almost ready to start writing our main program to parse the purchase order. First we need a test document. For this test I filled out the following information in a document called MyTestOrder.docx.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc5_2.jpg"&gt;&lt;img height="540" alt="wordcc5" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc5_thumb.jpg" width="654" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now we can write our main program:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Module &lt;/span&gt;Module1

    &lt;span style="color: blue"&gt;Sub &lt;/span&gt;Main()
        &lt;span style="color: blue"&gt;Try
            Dim &lt;/span&gt;docFile = &lt;span style="color: blue"&gt;My&lt;/span&gt;.Computer.FileSystem.GetFileInfo(&lt;span style="color: #a31515"&gt;&amp;quot;MyTestOrder.docx&amp;quot;&lt;/span&gt;)

            &lt;span style="color: blue"&gt;Dim &lt;/span&gt;docData &lt;span style="color: blue"&gt;As &lt;/span&gt;DocumentOrderData
            &lt;span style="color: blue"&gt;Using &lt;/span&gt;sr = docFile.OpenRead()
                &lt;span style="color: green"&gt;'Attempt to parse the document for order data
                &lt;/span&gt;docData = ParseOrderDocument(sr)
                sr.Close()
            &lt;span style="color: blue"&gt;End Using

            If &lt;/span&gt;docData &lt;span style="color: blue"&gt;IsNot Nothing Then
                Dim &lt;/span&gt;employeeEmail = &lt;span style="color: #a31515"&gt;&amp;quot;sales@nwtraders.com&amp;quot;

                &lt;/span&gt;&lt;span style="color: green"&gt;'Attempt to add the order data through the service
                &lt;/span&gt;AddNewOrder(docData, employeeEmail)
                Console.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;Order saved successfully.&amp;quot;&lt;/span&gt;)
            &lt;span style="color: blue"&gt;Else
                &lt;/span&gt;Console.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;No order data was found in the document.&amp;quot;&lt;/span&gt;)
            &lt;span style="color: blue"&gt;End If

        Catch &lt;/span&gt;ex &lt;span style="color: blue"&gt;As &lt;/span&gt;Exception
            Console.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;Order could not be processed.&amp;quot; &lt;/span&gt;&amp;amp; vbCrLf &amp;amp; ex.ToString())
        &lt;span style="color: blue"&gt;End Try

        &lt;/span&gt;Console.ReadLine()
    &lt;span style="color: blue"&gt;End Sub&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;The ParseOrderDocument method is going to need to grab the XML data from our Custom XML parts as we iterate over the part collection. It's a collection because there can actually be many Custom XML definitions in our document. In order to make grabbing the XML data from the parts easier let's create an &lt;a href="http://msdn.microsoft.com/en-us/library/bb384936.aspx" target="_blank"&gt;Extension method&lt;/a&gt; that extends the OpenXMLPart type. I like to place Extension methods in a separate file called Extensions.vb:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;Imports &lt;/span&gt;DocumentFormat.OpenXml.Packaging
&lt;span style="color: blue"&gt;Imports &lt;/span&gt;System.IO
&lt;span style="color: blue"&gt;Imports &lt;/span&gt;System.Xml

&lt;span style="color: blue"&gt;Module &lt;/span&gt;Extensions

    &lt;span style="color: green"&gt;' Create an extension method so we can easily access the part XML
    &lt;/span&gt;&amp;lt;System.Runtime.CompilerServices.Extension()&amp;gt; _
    &lt;span style="color: blue"&gt;Function &lt;/span&gt;GetXDocument(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;part &lt;span style="color: blue"&gt;As &lt;/span&gt;OpenXmlPart) &lt;span style="color: blue"&gt;As &lt;/span&gt;XDocument
        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;xdoc &lt;span style="color: blue"&gt;As &lt;/span&gt;XDocument

        &lt;span style="color: blue"&gt;Using &lt;/span&gt;sr &lt;span style="color: blue"&gt;As New &lt;/span&gt;StreamReader(part.GetStream())
            xdoc = XDocument.Load(XmlReader.Create(sr))
            sr.Close()
        &lt;span style="color: blue"&gt;End Using

        Return &lt;/span&gt;xdoc
    &lt;span style="color: blue"&gt;End Function
End Module&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now we can go back to our main Module1 and add a the ParseOrderDocument method. Notice that I'm using the Extension method we created in the For Each part... loop to return the custom XML as an XDocument. Then I use the child axis property &amp;lt;OrderEntry&amp;gt; (displayed in IntelliSense as I type the query) to see if the element exists. Also notice that since I imported our XML namespace at the top of the file it will only return an &amp;lt;OrderEntry&amp;gt; element in that namespace. So we're safe not to clash with other custom XML that may be added to the document by other processes.&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;pre class="code"&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;
&lt;/span&gt;&lt;span style="color: green"&gt;''' Attempts to parse the word document for order data and returns an order
'''  object with all the required. The document must have a customXML part 
'''  that adheres to the OrderEntry.xsd
''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;
&lt;/span&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name=&amp;quot;docStream&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The document to parse&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;
&lt;/span&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The order data contained in the document&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/returns&amp;gt;
&lt;/span&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;Function &lt;/span&gt;ParseOrderDocument(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;docStream &lt;span style="color: blue"&gt;As &lt;/span&gt;Stream) &lt;span style="color: blue"&gt;As &lt;/span&gt;DocumentOrderData
    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;orderData &lt;span style="color: blue"&gt;As &lt;/span&gt;DocumentOrderData = &lt;span style="color: blue"&gt;Nothing

    Try
        &lt;/span&gt;&lt;span style="color: green"&gt;'Use the Open XML SDK to open the document and access parts easily
        &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;wordDoc = WordprocessingDocument.Open(docStream, &lt;span style="color: blue"&gt;False&lt;/span&gt;)

        &lt;span style="color: blue"&gt;Using &lt;/span&gt;wordDoc
            &lt;span style="color: green"&gt;'Get the main document part (document.xml)
            &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;mainPart = wordDoc.MainDocumentPart
            &lt;span style="color: blue"&gt;Dim &lt;/span&gt;docXML &lt;span style="color: blue"&gt;As &lt;/span&gt;XElement = &lt;span style="color: blue"&gt;Nothing

            &lt;/span&gt;&lt;span style="color: green"&gt;'Find the order data custom XML part
            &lt;/span&gt;&lt;span style="color: blue"&gt;For Each &lt;/span&gt;part &lt;span style="color: blue"&gt;In &lt;/span&gt;mainPart.CustomXmlParts
                docXML = part.GetXDocument.&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;OrderEntry&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.FirstOrDefault()
                &lt;span style="color: blue"&gt;If &lt;/span&gt;docXML &lt;span style="color: blue"&gt;IsNot Nothing Then
                    Exit For
                End If
            Next

            If &lt;/span&gt;docXML &lt;span style="color: blue"&gt;Is Nothing Then
                Throw New &lt;/span&gt;InvalidOperationException(&lt;span style="color: #a31515"&gt;&amp;quot;This document does not contain order entry data.&amp;quot;&lt;/span&gt;)
            &lt;span style="color: blue"&gt;End If

            &lt;/span&gt;&lt;span style="color: green"&gt;'Grab the order data fields from the XML 
            &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;customerID = docXML.&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;CustomerID&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.Value.Trim()
            &lt;span style="color: blue"&gt;Dim &lt;/span&gt;orderDate = docXML.&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;OrderDate&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.Value.Trim()
            &lt;span style="color: blue"&gt;Dim &lt;/span&gt;shipper = docXML.&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;Shipper&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.Value.Trim()

            &lt;span style="color: blue"&gt;If &lt;/span&gt;customerID &amp;lt;&amp;gt; &lt;span style="color: #a31515"&gt;&amp;quot;&amp;quot; &lt;/span&gt;&lt;span style="color: blue"&gt;AndAlso &lt;/span&gt;IsDate(orderDate) &lt;span style="color: blue"&gt;Then
                &lt;/span&gt;&lt;span style="color: green"&gt;'Create and fill the DocumentOrderData  
                &lt;/span&gt;orderData = &lt;span style="color: blue"&gt;New &lt;/span&gt;DocumentOrderData(customerID, &lt;span style="color: blue"&gt;CDate&lt;/span&gt;(orderDate), shipper)

                &lt;span style="color: blue"&gt;For Each &lt;/span&gt;item &lt;span style="color: blue"&gt;In &lt;/span&gt;docXML.&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;OrderDetails&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;OrderDetail&lt;span style="color: #6464b9"&gt;&amp;gt;
                    &lt;/span&gt;&lt;span style="color: green"&gt;'Grab order details data fields
                    &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;product = item.&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;ProductName&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.Value.Trim()
                    &lt;span style="color: blue"&gt;Dim &lt;/span&gt;quantity = item.&lt;span style="color: #6464b9"&gt;&amp;lt;&lt;/span&gt;Quantity&lt;span style="color: #6464b9"&gt;&amp;gt;&lt;/span&gt;.Value.Trim()

                    &lt;span style="color: blue"&gt;If &lt;/span&gt;product &amp;lt;&amp;gt; &lt;span style="color: #a31515"&gt;&amp;quot;&amp;quot; &lt;/span&gt;&lt;span style="color: blue"&gt;AndAlso &lt;/span&gt;IsNumeric(quantity) &lt;span style="color: blue"&gt;Then
                        &lt;/span&gt;&lt;span style="color: green"&gt;'Add a new DocumentOrderData.Detail for each product found
                        &lt;/span&gt;orderData.Details.Add(&lt;span style="color: blue"&gt;New &lt;/span&gt;DocumentOrderData.Detail(product, &lt;span style="color: blue"&gt;CShort&lt;/span&gt;(quantity)))
                    &lt;span style="color: blue"&gt;End If

                Next
            End If
            &lt;/span&gt;wordDoc.Close()
        &lt;span style="color: blue"&gt;End Using

    Catch &lt;/span&gt;ex &lt;span style="color: blue"&gt;As &lt;/span&gt;Exception
        &lt;span style="color: blue"&gt;Throw New &lt;/span&gt;InvalidOperationException(&lt;span style="color: #a31515"&gt;&amp;quot;Could not process this document.&amp;quot;&lt;/span&gt;, ex)
    &lt;span style="color: blue"&gt;End Try

    Return &lt;/span&gt;orderData
&lt;span style="color: blue"&gt;End Function&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;&lt;strong&gt;Updating the Database through the Data Service&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our document parsed we're just left with adding the data through our data service.&amp;#160; What we need to do is query the reference data (entities) that we'll need to properly associate on our Order. For instance Order will need a reference to the Customer, the Employee and the Shipper. Then each Order_Detail will need a reference to the Product entity. Notice that we're passing the employee email address into this method so that we can associate the sales rep with the order. &lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/02/03/oba-part-1-exposing-line-of-business-data.aspx" target="_blank"&gt;If you recall we had to add this field&lt;/a&gt; to the Customer and Employee tables in Northwind. (For this test program I'm hard-coding the value but later we'll get this information from the Outlook client when it submits the order to SharePoint.)&lt;/p&gt;

&lt;p&gt;Once we have these entities queried and returned from the service we can link them up properly and add our new Order and Order_Details to the data service. For more information on updating data and setting proper linkage to entities returned from an ADO.NET data service &lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/01/20/ado-net-data-services-enforcing-fk-associations-and-a-fix-for-deleting-entities.aspx" target="_blank"&gt;read this post&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/phaniraj/archive/2008/07/02/working-with-relations-in-ado-net-data-services-beta-1.aspx" target="_blank"&gt;this one&lt;/a&gt;. &lt;/p&gt;

&lt;pre class="code"&gt;    &lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;summary&amp;gt;
    &lt;/span&gt;&lt;span style="color: green"&gt;''' Adds a new order through the ADO.NET Data service and sets up all the required
    ''' associations to related entities.
    ''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/summary&amp;gt;
    &lt;/span&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name=&amp;quot;docData&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The order data&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;param name=&amp;quot;employeeEmail&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;EmailAddress of sales representitve&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: green"&gt;''' &lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;Private Sub &lt;/span&gt;AddNewOrder(&lt;span style="color: blue"&gt;ByVal &lt;/span&gt;docData &lt;span style="color: blue"&gt;As &lt;/span&gt;DocumentOrderData, &lt;span style="color: blue"&gt;ByVal &lt;/span&gt;employeeEmail &lt;span style="color: blue"&gt;As String&lt;/span&gt;)

        &lt;span style="color: blue"&gt;Dim &lt;/span&gt;ctx &lt;span style="color: blue"&gt;As New &lt;/span&gt;NorthwindEntities(&lt;span style="color: blue"&gt;New &lt;/span&gt;Uri(&lt;span style="color: #a31515"&gt;&amp;quot;http://localhost:1234/Northwind.svc/&amp;quot;&lt;/span&gt;))
      &lt;span style="color: blue"&gt;  Dim &lt;/span&gt;cust &lt;span style="color: blue"&gt;As &lt;/span&gt;Customer
        &lt;span style="color: blue"&gt;Try
            &lt;/span&gt;&lt;span style="color: green"&gt;'Try to retrieve the customer
            &lt;/span&gt;cust = (&lt;span style="color: blue"&gt;From &lt;/span&gt;c &lt;span style="color: blue"&gt;In &lt;/span&gt;ctx.Customers _
                     &lt;span style="color: blue"&gt;Where &lt;/span&gt;c.CustomerID = docData.CustomerID).FirstOrDefault()

        &lt;span style="color: blue"&gt;Catch &lt;/span&gt;ex &lt;span style="color: blue"&gt;As &lt;/span&gt;Exception
            &lt;span style="color: blue"&gt;Throw New &lt;/span&gt;InvalidOperationException(&lt;span style="color: #a31515"&gt;&amp;quot;Invalid customer ID.&amp;quot;&lt;/span&gt;)&lt;span style="color: blue"&gt;
        End Try

        If &lt;/span&gt;cust &lt;span style="color: blue"&gt;IsNot Nothing Then

            Dim &lt;/span&gt;ship = (&lt;span style="color: blue"&gt;From &lt;/span&gt;s &lt;span style="color: blue"&gt;In &lt;/span&gt;ctx.Shippers _
                        &lt;span style="color: blue"&gt;Where &lt;/span&gt;s.CompanyName = docData.Shipper).FirstOrDefault()

            &lt;span style="color: green"&gt;'Email Address will come from our Outlook client/sales person 
            &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;emp = (&lt;span style="color: blue"&gt;From &lt;/span&gt;e &lt;span style="color: blue"&gt;In &lt;/span&gt;ctx.Employees _
                       &lt;span style="color: blue"&gt;Where &lt;/span&gt;e.EmailAddress = employeeEmail).FirstOrDefault()

            &lt;span style="color: blue"&gt;Dim &lt;/span&gt;o &lt;span style="color: blue"&gt;As New &lt;/span&gt;Order()

            o.OrderDate = docData.OrderDate
            o.RequiredDate = Now.AddDays(2)
            o.ShipAddress = cust.Address
            o.ShipCity = cust.City
            o.ShipCountry = cust.Country
            o.ShipName = cust.ContactName
            o.ShipPostalCode = cust.PostalCode
            o.ShipRegion = cust.Region
            o.Freight = 25

            ctx.AddToOrders(o)

            o.Customer = cust
            ctx.SetLink(o, &lt;span style="color: #a31515"&gt;&amp;quot;Customer&amp;quot;&lt;/span&gt;, cust)

            &lt;span style="color: blue"&gt;If &lt;/span&gt;ship &lt;span style="color: blue"&gt;IsNot Nothing Then
                &lt;/span&gt;o.Shipper = ship
                ctx.SetLink(o, &lt;span style="color: #a31515"&gt;&amp;quot;Shipper&amp;quot;&lt;/span&gt;, ship)
            &lt;span style="color: blue"&gt;End If

            If &lt;/span&gt;emp &lt;span style="color: blue"&gt;IsNot Nothing Then
                &lt;/span&gt;o.Employee = emp
                ctx.SetLink(o, &lt;span style="color: #a31515"&gt;&amp;quot;Employee&amp;quot;&lt;/span&gt;, emp)
            &lt;span style="color: blue"&gt;End If

            &lt;/span&gt;o.Order_Details = &lt;span style="color: blue"&gt;New &lt;/span&gt;System.Collections.ObjectModel.Collection(&lt;span style="color: blue"&gt;Of &lt;/span&gt;Order_Detail)

            &lt;span style="color: blue"&gt;For Each &lt;/span&gt;item &lt;span style="color: blue"&gt;In &lt;/span&gt;docData.Details
                &lt;span style="color: blue"&gt;Dim &lt;/span&gt;productName = item.ProductName.ToLower()
                &lt;span style="color: blue"&gt;Dim &lt;/span&gt;product = (&lt;span style="color: blue"&gt;From &lt;/span&gt;p &lt;span style="color: blue"&gt;In &lt;/span&gt;ctx.Products _
                               &lt;span style="color: blue"&gt;Where &lt;/span&gt;p.ProductName.ToLower() = productName).FirstOrDefault()

                &lt;span style="color: blue"&gt;If &lt;/span&gt;product &lt;span style="color: blue"&gt;IsNot Nothing Then
                    &lt;/span&gt;&lt;span style="color: green"&gt;'Create a detail for each product being ordered
                    &lt;/span&gt;&lt;span style="color: blue"&gt;Dim &lt;/span&gt;detail &lt;span style="color: blue"&gt;As New &lt;/span&gt;Order_Detail()
                    o.Order_Details.Add(detail)

                    detail.Quantity = item.Quantity
                    detail.UnitPrice = &lt;span style="color: blue"&gt;If&lt;/span&gt;(product.UnitPrice.HasValue, _
                                          product.UnitPrice.Value, 1D)

                    ctx.AddToOrder_Details(detail)

                    detail.Product = product
                    ctx.SetLink(detail, &lt;span style="color: #a31515"&gt;&amp;quot;Product&amp;quot;&lt;/span&gt;, product)

                    detail.Order = o
                    ctx.SetLink(detail, &lt;span style="color: #a31515"&gt;&amp;quot;Order&amp;quot;&lt;/span&gt;, o)

                    ctx.AddLink(o, &lt;span style="color: #a31515"&gt;&amp;quot;Order_Details&amp;quot;&lt;/span&gt;, detail)
                &lt;span style="color: blue"&gt;End If
            Next
            &lt;/span&gt;&lt;span style="color: green"&gt;'Saving in Batch mode will update the data inside a database transaction
            'This will throw an exception if the service can't save the Order
            &lt;/span&gt;ctx.SaveChanges(Services.Client.SaveChangesOptions.Batch)
        &lt;span style="color: blue"&gt;End If
    End Sub
End Module&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;When we run this program we will see that Customer ALFKI now has a new Order and 4 Order Details entered into the database. Since we're sending the updates in Batch mode this will cause our order data to be properly wrapped in a database transaction.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc6_2.jpg"&gt;&lt;img height="509" alt="wordcc6" src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/OBAPart3ReadingDatafromWordDocuments_DE22/wordcc6_thumb.jpg" width="666" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Next post we'll talk about how we can create a SharePoint workflow to run this code when order documents are added to a SharePoint list. However, if SharePoint is not a requirement of your system (maybe you have no need to collaborate on documents or store this unstructured data) you could easily add this code directly to the &lt;a href="http://blogs.msdn.com/bethmassi/archive/2009/02/07/oba-part-2-building-and-outlook-client-against-lob-data.aspx" target="_blank"&gt;Outlook client we built in the previous post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I updated &lt;a href="http://code.msdn.microsoft.com/OBANorthwind" target="_blank"&gt;the sample on Code Gallery&lt;/a&gt; with this project so have a look. &lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9416665" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/ADO.NET+Data+Services/default.aspx">ADO.NET Data Services</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/OBA/default.aspx">OBA</category></item><item><title>WPF RSS Feed Aggregator on CodePlex</title><link>http://blogs.msdn.com/bethmassi/archive/2008/11/12/wpf-rss-feed-aggregator-on-codeplex.aspx</link><pubDate>Thu, 13 Nov 2008 03:30:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9064782</guid><dc:creator>Beth Massi</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9064782.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9064782</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9064782</wfw:comment><description>&lt;p&gt;&lt;a href="http://community.visual-basic.it/Alessandro" target="_blank"&gt;Alessandro Del Sole&lt;/a&gt;, Visual Basic MVP, &lt;a href="http://www.codeplex.com/CustomFeedAggregator" target="_blank"&gt;&lt;strong&gt;has been busy on CodePlex&lt;/strong&gt;&lt;/a&gt; writing a neat WPF learning application that aggregates RSS feeds. In his words:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;It's developed in &lt;b&gt;Visual Basic 2008&lt;/b&gt; and uses &lt;b&gt;LINQ-to-Xml&lt;/b&gt; and &lt;b&gt;XML Literals&lt;/b&gt; to read feeds and persist XML data. You'll learn a lot of things like:&lt;/em&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;em&gt;WPF &lt;b&gt;Styles&lt;/b&gt; and &lt;b&gt;control templates&lt;/b&gt;;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;WPF &lt;b&gt;Data-binding&lt;/b&gt;;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;WPF &lt;b&gt;color animations&lt;/b&gt;;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;&lt;b&gt;Creating a Grid&lt;/b&gt; to show data in WPF;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;&lt;b&gt;LINQ-to-Xml&lt;/b&gt; query expressions and embedded expressions in Visual Basic 2008;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;&lt;b&gt;XML Literals&lt;/b&gt; in Visual Basic 2008;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;Enabling IntelliSense for LINQ-to-XML with &lt;b&gt;XML Schema Inference&lt;/b&gt;&lt;/em&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I just started playing with it myself and it's pretty cool. I wrote a &lt;a href="http://code.msdn.microsoft.com/vstipoftheday/" target="_blank"&gt;mini feed browser to search Sara's Visual Studio Tip of the Day posts&lt;/a&gt; using XML Literals that can cache the posts as well. I'll probably try to update it in WPF as well based on this. Thanks Alessandro!&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9064782" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category></item><item><title>SDN Conference Day 2</title><link>http://blogs.msdn.com/bethmassi/archive/2008/10/08/sdn-conference-day-2.aspx</link><pubDate>Wed, 08 Oct 2008 13:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8986051</guid><dc:creator>Beth Massi</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/8986051.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=8986051</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=8986051</wfw:comment><description>&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/SDC_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/SDC_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; MARGIN: 0px 0px 0px 10px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=322 alt=SDC src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/SDC_thumb.jpg" width=462 align=right border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/SDC_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Today I woke up at the crack of dawn because I had an 8:30 AM session. Okay maybe not quite the crack, but for me it was &lt;STRONG&gt;&lt;EM&gt;early&lt;/EM&gt;&lt;/STRONG&gt;. Especially after a night of socializing. That's a really cool thing about conferences here, the attendees love to go out with you after dinner and uh.. socialize. ;-) There were a lot of great conversations about technology flying everywhere it was hard to keep up. I crashed about 1 AM (which everyone told me was early!) and woke up about an hour and a half before my talk, no problem.&lt;/P&gt;
&lt;P&gt;This talk I've done many times before and it's one of my most favorite subjects -- &lt;A href="http://msdn.microsoft.com/en-us/library/bb384629.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb384629.aspx"&gt;XML Literals&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/bb384460.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb384460.aspx"&gt;LINQ to XML in Visual Basic&lt;/A&gt;. I've done variations of this talk at user groups, other &lt;A href="http://blogs.msdn.com/bethmassi/archive/2008/04/30/video-presentation-conquering-xml-with-linq-in-visual-basic-9.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2008/04/30/video-presentation-conquering-xml-with-linq-in-visual-basic-9.aspx"&gt;conferences&lt;/A&gt; and &lt;A href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032374409&amp;amp;EventCategory=5&amp;amp;culture=en-US&amp;amp;CountryCode=US" target=_blank mce_href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032374409&amp;amp;EventCategory=5&amp;amp;culture=en-US&amp;amp;CountryCode=US"&gt;webcasts&lt;/A&gt;. And I showed a lot of the techniques that I've &lt;A href="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/XML/default.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/XML/default.aspx"&gt;written about here&lt;/A&gt; as well as &lt;A href="http://www.code-magazine.com/article.aspx?quickid=0807061" target=_blank mce_href="http://www.code-magazine.com/article.aspx?quickid=0807061"&gt;this article&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/magazine/cc947916.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/magazine/cc947916.aspx"&gt;this one&lt;/A&gt;. This was my best session according to the ratings but it's so easy to do well with this talk because of the simple and powerful expressiveness of XML in VB. It doesn't take much code at all to start creating, querying and manipulating XML documents directly in the editor with this awesome feature. Check out the &lt;A href="http://blogs.msdn.com/vbteam" target=_blank mce_href="http://blogs.msdn.com/vbteam"&gt;VB Team blog&lt;/A&gt; where &lt;A href="http://blogs.msdn.com/vbteam/archive/tags/VB+XML+Cookbook/default.aspx" target=_blank mce_href="http://blogs.msdn.com/vbteam/archive/tags/VB+XML+Cookbook/default.aspx"&gt;Doug Rothaus is doing a series of posts on XML in VB&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0942.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0942.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; MARGIN: 0px 10px 5px 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=192 alt=IMG_0942 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0942_thumb.jpg" width=254 align=left border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0942_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I also attended Brian Noyes' session on WPF Data Binding. Since I've &lt;A href="http://blogs.msdn.com/bethmassi/archive/2008/09/24/data-sources-and-data-binding-in-wpf-talk-in-redmond.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2008/09/24/data-sources-and-data-binding-in-wpf-talk-in-redmond.aspx"&gt;been speaking about this as well&lt;/A&gt; I thought I'd join him and compare notes. ;-). I also told him about what scenarios I was going to tackle next on my &lt;A href="http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx#wpfdata" target=_blank mce_href="http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx#wpfdata"&gt;WPF Forms over Data video series&lt;/A&gt; and he validated where I was going with it. It's great to chat with experts building business applications because I've built many in my life as well and the challenges are always similar. Brian is one of my data binding heroes since he wrote his &lt;A href="http://www.amazon.com/Data-Binding-Windows-Forms-2-0/dp/032126892X" target=_blank mce_href="http://www.amazon.com/Data-Binding-Windows-Forms-2-0/dp/032126892X"&gt;Data Binding in Windows Forms 2.0&lt;/A&gt; (which I still highly recommend). &lt;/P&gt;
&lt;P&gt;Although there were a ton of .NET sessions, there were also a lot of Delphi sessions as well as a co-conference &lt;A href="http://www.openforce08.com/" target=_blank mce_href="http://www.openforce08.com/"&gt;DotNetNuke OpenForce&lt;/A&gt; at this venue. I met a lot of cool people in the software industry. &lt;/P&gt;
&lt;P&gt;The final wrap up was a bunch of cool give-aways for the attendees including a Wii and a Blue-Ray disk player -- very cool! I took a few pictures of some of the speakers and organizers...some of them acting pretty goofy.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0959.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0959.jpg"&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0954_1.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0954_1.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=171 alt=IMG_0954 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0954_thumb_1.jpg" width=226 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0954_thumb_1.jpg"&gt;&lt;/A&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=172 alt=IMG_0959 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0959_thumb.jpg" width=227 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0959_thumb.jpg"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0937.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0937.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=173 alt=IMG_0937 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0937_thumb.jpg" width=229 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0937_thumb.jpg"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0957.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0957.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=172 alt=IMG_0957 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0957_thumb.jpg" width=228 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0957_thumb.jpg"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0945.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0945.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=170 alt=IMG_0945 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0945_thumb.jpg" width=225 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0945_thumb.jpg"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0938.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0938.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=172 alt=IMG_0938 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0938_thumb.jpg" width=228 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0938_thumb.jpg"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0951.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0951.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=171 alt=IMG_0951 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0951_thumb.jpg" width=227 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0951_thumb.jpg"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0949.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0949.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=171 alt=IMG_0949 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0949_thumb.jpg" width=227 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0949_thumb.jpg"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0958.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0958.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=173 alt=IMG_0958 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0958_thumb.jpg" width=229 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/SDNConferenceDay2_F50D/IMG_0958_thumb.jpg"&gt;&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Tomorrow I head back to Amsterdam where the organizers are going to take the speakers on a Holland tour. I can't wait!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8986051" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Speaking/default.aspx">Speaking</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category></item><item><title>First Day at SDN Conference</title><link>http://blogs.msdn.com/bethmassi/archive/2008/10/07/first-day-at-sdn-conference.aspx</link><pubDate>Tue, 07 Oct 2008 13:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8984087</guid><dc:creator>Beth Massi</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/8984087.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=8984087</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=8984087</wfw:comment><description>&lt;P&gt;I'm here in the Netherlands in a town called Noordwijkerhout near Amsterdam at the &lt;A href="http://www.sdc.nl/" target=_blank mce_href="http://www.sdc.nl"&gt;SDN Conference&lt;/A&gt; with a lot of &lt;A href="http://www.sdc.nl/Default.aspx?tabid=71&amp;amp;language=en-US" target=_blank mce_href="http://www.sdc.nl/Default.aspx?tabid=71&amp;amp;language=en-US"&gt;great speakers and sessions&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0933.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0933.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=173 alt=IMG_0933 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0933_thumb.jpg" width=229 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0933_thumb.jpg"&gt;&lt;/A&gt;&amp;nbsp;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0934.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0934.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=173 alt=IMG_0934 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0934_thumb.jpg" width=231 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0934_thumb.jpg"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0935_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0935_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=173 alt=IMG_0935 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0935_thumb_2.jpg" width=229 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/FirstDayatSDNConference_9B48/IMG_0935_thumb_2.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I took these shots while the attendees were in session. There's good food, great vendors and lots of entertainment -- XBoxes, bowling, pin-pong, and lots of bars ;-) We also had a really funny English comedian perform at the end of the night. The Dutch really know how to put on a great event. &lt;/P&gt;
&lt;P&gt;I have a total of three sessions and two on the first day. First I did a session called &lt;A href="http://www.sdc.nl/Default.aspx?tabid=71&amp;amp;language=en-US" target=_blank mce_href="http://www.sdc.nl/Default.aspx?tabid=71&amp;amp;language=en-US"&gt;&lt;EM&gt;LINQ to Everything&lt;/EM&gt;&lt;/A&gt; where I walked through each of the LINQ providers in Visual Studio 2008 SP1 "box" including &lt;A href="http://msdn.microsoft.com/en-us/library/bb386976.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb386976.aspx"&gt;LINQ to SQL&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/bb386977.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb386977.aspx"&gt;LINQ to DataSet&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx"&gt;LINQ to Entities&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/bb384460.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb384460.aspx"&gt;LINQ to XML&lt;/A&gt;. We discussed application architecture and considerations and I showed demos to introduce each of the technologies. The room was packed and I got great scores so I'd say it went well. :-)&lt;/P&gt;
&lt;P&gt;Next session I did was a lot of fun. It was called &lt;A href="http://www.sdc.nl/Default.aspx?tabid=71&amp;amp;language=en-US" target=_blank mce_href="http://www.sdc.nl/Default.aspx?tabid=71&amp;amp;language=en-US"&gt;&lt;EM&gt;Taking Advantage of LINQ and Open XML in Office 2007&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;and I showed how to manipulate Open XML document formats in Office 2007 Word, PowerPoint and Excel documents using the &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&amp;amp;DisplayLang=en"&gt;Open XML SDK version 2.0&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/bb384460.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb384460.aspx"&gt;LINQ to XML&lt;/A&gt;. I think it sparked a lot of people's curiosity and creativity because there are a lot of possibilities. I showed how you can create, query and transform documents without having to have Office installed at all. I also had great reviews and chatted with many attendees afterwards who were building a lot of cool business applications.&lt;/P&gt;
&lt;P&gt;I &lt;A class="" href="http://blogs.msdn.com/bethmassi/attachment/8984087.ashx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/attachment/8984087.ashx"&gt;attached the prese&lt;/A&gt;ntation and demos so have a look.&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8984087" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/bethmassi/attachment/8984087.ashx" length="3272804" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Speaking/default.aspx">Speaking</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>MSDN Magazine - Dynamic Data Entry With XML Literals</title><link>http://blogs.msdn.com/bethmassi/archive/2008/10/01/msdn-magazine-dynamic-data-entry-with-xml-literals.aspx</link><pubDate>Thu, 02 Oct 2008 04:49:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8972596</guid><dc:creator>Beth Massi</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/8972596.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=8972596</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=8972596</wfw:comment><description>&lt;p&gt;Check out the latest news on the &lt;a href="http://msdn.microsoft.com/en-us/vbasic/default.aspx" target="_blank"&gt;VB Dev Center&lt;/a&gt;. I'm finally headlining myself ;-) &lt;/p&gt;  &lt;p&gt;I'm in the &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc947916.aspx" target="_blank"&gt;October issue of MSDN Magazine&lt;/a&gt;. I've been managing the content for the Basic Instincts column for a little over a year now where we rotate writers from the VB Team. This month is my birthday month so I decided to take this one on personally. :-)&lt;/p&gt;  &lt;p&gt;Enjoy! &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8972596" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>Channel 9 Interview: XML Schema Explorer in Visual Studio 2008 SP1</title><link>http://blogs.msdn.com/bethmassi/archive/2008/08/15/channel-9-interview-xml-schema-explorer-in-visual-studio-2008-sp1.aspx</link><pubDate>Fri, 15 Aug 2008 22:18:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8870467</guid><dc:creator>Beth Massi</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/8870467.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=8870467</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=8870467</wfw:comment><description>&lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/funkyonex/XML-Schema-Explorer-in-Visual-Studio-2008-SP1/" target="_blank"&gt;I just posted an interview on Channel 9 with Yang Xiao&lt;/a&gt;, a tester on the VB IDE. In this interview Yang shows us the new XML Schema Explorer in &lt;a href="http://msdn.microsoft.com/en-us/vstudio/products/cc533448.aspx"&gt;Visual Studio 2008 Service Pack 1&lt;/a&gt;. This new window is invoked when you right-click on an XML literal element or namespace and select &amp;quot;Show in XML Schema Explorer&amp;quot; in Visual Basic programs. It's a nice way to visually display the structure of your schema sets which makes you even more productive when working with XML in Visual Basic. &lt;/p&gt;  &lt;p&gt;&lt;iframe src="http://channel9.msdn.com/posts/funkyonex/421686/player/" frameborder="0" width="320" scrolling="no" height="325"&gt;&lt;/iframe&gt;    &lt;br /&gt;&lt;a href="http://channel9.msdn.com/posts/funkyonex/XML-Schema-Explorer-in-Visual-Studio-2008-SP1/"&gt;XML Schema Explorer in Visual Studio 2008 SP1&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8870467" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Channel9/default.aspx">Channel9</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/XML/default.aspx">XML</category></item></channel></rss>