<?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>Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx</link><description>Last week I had a chance to write some interesting code samples. I missed coding a lot, and I felt a little rusty after working in different projects. But I had a lot of fun and I want to share with you one of the samples I wrote: A simple ASP.NET 2.0</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Interesting Finds: August 10 part 2 and August 11, 2006</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#696192</link><pubDate>Sat, 12 Aug 2006 06:24:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:696192</guid><dc:creator>Jason Haley</dc:creator><description /></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#698808</link><pubDate>Mon, 14 Aug 2006 02:53:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:698808</guid><dc:creator>Edje</dc:creator><description>Thanks very much for this Erika, I sincerely hope part two will deal with 'collections' as in adding a table with repeating data. &amp;nbsp;I am currently dealing with that using XSLT which is very cumbersome especially when you need to update and deploy.&lt;br&gt;&lt;br&gt;I love your posts!</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#700081</link><pubDate>Mon, 14 Aug 2006 23:44:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:700081</guid><dc:creator>Brett</dc:creator><description>I love this idea. One question, now that you have created the Word 2007 file on the server, what tools could you use to convert the document into a Word 2003 or XP file for download by users who haven't got Office 2007?</description></item><item><title>Data-driven document generation with Word 2007 and the Office XML File Formats: Part 2</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#703089</link><pubDate>Thu, 17 Aug 2006 01:26:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:703089</guid><dc:creator>Erika Ehrli</dc:creator><description>You can build a server-side application using Visual Studio to generate data-rich documents using the Office XML File Formats and &amp;nbsp;the .NET Framework 3.0 (aka Microsoft WinFX ). Here's how...</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#712973</link><pubDate>Tue, 22 Aug 2006 21:27:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:712973</guid><dc:creator>erikaehrli</dc:creator><description>Edje:&lt;br&gt;&lt;br&gt;Thanks for the very nice comment :). Part 2 doesn't deal with WordML generation, it deals more with replacing a Word Content Control (placeholder) with custom xml data. To iterate a collection to add a custom table, you need to create the WordML file (document.xml part). You can use a XMLDocument or XMLTextWriter object to create a table element. I will keep in mind your request for a future blog entry :).&lt;br&gt;&lt;br&gt;Brett:&lt;br&gt;The only tool I know of is the &amp;quot;Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 File Formats (Beta 2).&amp;quot; &amp;nbsp; You can use this tool with your current version of Office (2003 and XP only) to be able to read and write the Office XML formats. You can download the tool here:&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://www.microsoft.com/office/preview/beta/converter.mspx"&gt;http://www.microsoft.com/office/preview/beta/converter.mspx&lt;/a&gt;&lt;br&gt;</description></item><item><title>Creating a rich Wordprocessing Document from a database</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#718744</link><pubDate>Thu, 24 Aug 2006 22:06:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:718744</guid><dc:creator>Brian Jones: Open XML Formats</dc:creator><description>I've been planning to start pulling together some real world examples around the ways in which people...</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#818517</link><pubDate>Thu, 12 Oct 2006 10:05:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:818517</guid><dc:creator>Qanuc</dc:creator><description>&lt;p&gt;Hi Erika!&lt;/p&gt;
&lt;p&gt;Great article, it helped me a lot.&lt;/p&gt;
&lt;p&gt;But now, i got a slight different problem:&lt;/p&gt;
&lt;p&gt;In my AddIn, it must be possible to add an entry to the CustomXmlPart, according to a given schema. Initially, the XML of the CustomXmlPart looks like &amp;quot;&amp;lt;MetaData&amp;gt;&amp;lt;/MetaData&amp;gt;&amp;quot;, and by clicking some button it should become &amp;quot;&amp;lt;MetaData&amp;gt;&amp;lt;Name&amp;gt;MySelf&amp;lt;/Name&amp;gt;&amp;lt;/MetaData&amp;gt;&amp;quot;. But, as the given schema I mentioned is very rich and flexible, I cannot pre-define all the fields.&lt;/p&gt;
&lt;p&gt;Now, I try the following:&lt;/p&gt;
&lt;p&gt;part = Globals.ThisAddIn.Application.ActiveDocument.CustomXMLParts.Add (&amp;quot;&amp;lt;MetaData&amp;gt;&amp;lt;/MetaData&amp;gt;&amp;quot;, System.Reflection.Missing.Value);&lt;/p&gt;
&lt;p&gt;---&amp;gt; The SchemaCollection of the newly created CustomXmlPart is empty.&lt;/p&gt;
&lt;p&gt;part.SchemaCollection.Add (&amp;quot;NameSpaceUri&amp;quot;, &amp;quot;SchemaAlias&amp;quot;, &amp;quot;(path to xsd file)&amp;quot;, false);&lt;/p&gt;
&lt;p&gt;When doing the SchemaCollection.Ad, I get the following exception:&lt;/p&gt;
&lt;p&gt;&amp;quot;System.Runtime.InteropServices.COMException (0xE0041802): This schema cannot be reloaded, as the schema collection is currently in use.&amp;quot;&lt;/p&gt;
&lt;p&gt;What is going wrong here? Any idea?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt; Michael&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#820605</link><pubDate>Thu, 12 Oct 2006 22:20:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:820605</guid><dc:creator>erikaehrli</dc:creator><description>&lt;p&gt;Hey Michael,&lt;/p&gt;
&lt;p&gt;Thanks for writing.&lt;/p&gt;
&lt;p&gt;The CustomXMLParts.Add method allows you to add a new valid Custom XML part, what you are adding is invalid. Try doing the following:&lt;/p&gt;
&lt;p&gt;ActiveDocument.CustomXMLParts.Add&lt;/p&gt;
&lt;p&gt;ActiveDocument.CustomXMLParts(4).LoadXML (&amp;quot;&amp;lt;?xml version='1.0'?&amp;gt;&amp;lt;MetaData&amp;gt;&amp;lt;Name&amp;gt;MySelf&amp;lt;/Name&amp;gt;&amp;lt;/MetaData&amp;gt;&amp;quot;)&lt;/p&gt;
&lt;p&gt;Where 4 is the index number of the CustomXMLPart. You can add more as needed.&lt;/p&gt;
&lt;p&gt;If you are trying to override an existing CustomXMLPart with new nodes,the best way is using the AddNode method.&lt;/p&gt;
&lt;p&gt;The model is similar to DOM.&lt;/p&gt;
&lt;p&gt;I hope this helps,&lt;/p&gt;
&lt;p&gt;-Erika&lt;/p&gt;
</description></item><item><title>Working with Open Packaging parts</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1082506</link><pubDate>Thu, 16 Nov 2006 00:21:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1082506</guid><dc:creator>OpenXML Developer</dc:creator><description>&lt;p&gt;Article submitted by: St&amp;#233;phane Rodriguez This article is a tutorial for working with parts as defined...&lt;/p&gt;
</description></item><item><title>Working with Open Packaging parts</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1082514</link><pubDate>Thu, 16 Nov 2006 00:24:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1082514</guid><dc:creator>OpenXML Developer</dc:creator><description>&lt;p&gt;Article submitted by: St&amp;#233;phane Rodriguez This article is a tutorial for working with parts as defined...&lt;/p&gt;
</description></item><item><title>Mapping problems</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1148562</link><pubDate>Sat, 25 Nov 2006 19:50:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1148562</guid><dc:creator>Akshay Dhavle</dc:creator><description>&lt;p&gt;Hi Erika,&lt;/p&gt;
&lt;p&gt;Nice article, though I'm afraid I am still clueless as to how to map a content control to an XML Element.&lt;/p&gt;
&lt;p&gt;Is there a way to do this through Word 2007? Can you guide me through the menus if possible?&lt;/p&gt;
&lt;p&gt;Thanks in advance.&lt;/p&gt;
&lt;p&gt;Akshay Dhavle&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1374100</link><pubDate>Thu, 28 Dec 2006 17:04:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1374100</guid><dc:creator>goodwill</dc:creator><description>&lt;p&gt;Akshay,&lt;/p&gt;
&lt;p&gt;Totally agree with you, I really dont understand why documentations are usually missing important points... IMHO its really a bit lousy.... Not everyone have the bandwidth to see the demo play...&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1438654</link><pubDate>Tue, 09 Jan 2007 12:39:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1438654</guid><dc:creator>Annette</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;is the mapping of Content Controls to XML only possible programatically? &lt;/p&gt;
&lt;p&gt;Would be glad if you can give me an answer&lt;/p&gt;
&lt;p&gt;(annette.ilgen(at)cataligent.com )&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1580784</link><pubDate>Fri, 02 Feb 2007 10:39:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1580784</guid><dc:creator>erikaehrli</dc:creator><description>&lt;p&gt;Ashkay, goodwill and Annette:&lt;/p&gt;
&lt;p&gt;There’s no UI to map controls to XML with one exception – SharePoint and Built-in properties are listed in the Quick Parts | Linked Properties fly out menu.&lt;/p&gt;
&lt;p&gt;You can map Content Controls to Custom XML parts.&lt;/p&gt;
&lt;p&gt;1. Using XMLMapping object (programmatically).&lt;/p&gt;
&lt;p&gt;2. Manually updating files inside of a document package. Here’s a great sample: &lt;a rel="nofollow" target="_new" href="http://openxmldeveloper.org/archive/2006/06/04/Mapping_Content_Controls_to_Custom_XML_Parts_using_Notepad.aspx"&gt;http://openxmldeveloper.org/archive/2006/06/04/Mapping_Content_Controls_to_Custom_XML_Parts_using_Notepad.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;3.Using the System.IO.Packaging class to programmatically manipulate the package and create the item.xml parts and the relationships.&lt;/p&gt;
&lt;p&gt;I promise to blog about this soon to clarify a bit more.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1608456</link><pubDate>Tue, 06 Feb 2007 06:18:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1608456</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi Erika,&lt;/p&gt;
&lt;p&gt;Can you help me? I created a task pane using visual studio tools for office. This task pane have a list list of customers from a database and displays them in a grid. &lt;/p&gt;
&lt;p&gt;How can I mapping this information into a plain text content control?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Jason&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1647629</link><pubDate>Sun, 11 Feb 2007 05:12:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1647629</guid><dc:creator>Peter Verster</dc:creator><description>&lt;p&gt;I have used your sample to create a similar implementation in VSTO using C#. I anayone is interested i can make this available.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1670828</link><pubDate>Tue, 13 Feb 2007 22:47:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1670828</guid><dc:creator>Flavia</dc:creator><description>&lt;p&gt;Here is a link to view a video...how to link CC to xml data files using a ready-to-use toolkit... Source code also available...pretty neat i think&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://channel9.msdn.com/ShowPost.aspx?PostID=254539"&gt;http://channel9.msdn.com/ShowPost.aspx?PostID=254539&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#1829368</link><pubDate>Wed, 07 Mar 2007 20:12:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1829368</guid><dc:creator>adam</dc:creator><description>&lt;p&gt;Are there plans to support a datagrid (or a table) type of content control. &amp;nbsp;I need to report on a list of data and do not see an obvious way of doing this without manually writing all the code to create a table.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#2315890</link><pubDate>Sun, 29 Apr 2007 00:46:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2315890</guid><dc:creator>Adriaan</dc:creator><description>&lt;p&gt;I am a php website developer, but I have to say that these tools that MS are making available are really cool... thanks for the info, I really found it quite useful.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#2362096</link><pubDate>Tue, 01 May 2007 22:51:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2362096</guid><dc:creator>Joe Sweeney</dc:creator><description>&lt;p&gt;I found these directions very confusing for a first-timer using Word 2007. The steps to accomplish the task are not very direct or clear. I speak as an adjunct instructor at a community college for eight years. It took me a while to find the toolbar options that would allow me to add the text controls and to open a VBA window.&lt;/p&gt;
&lt;p&gt;However, once I found everything, it worked like a charm.&lt;/p&gt;
</description></item><item><title>Migrate Office 2003 documents to Office 2007 documents and what is happen with the old doc-properties?</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#2874326</link><pubDate>Fri, 25 May 2007 18:29:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2874326</guid><dc:creator>Microsoft Office SharePoint and related</dc:creator><description>&lt;p&gt;We are going the way to use more XML based content. This makes us more flexible with further ideas but&lt;/p&gt;
</description></item><item><title /><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#2874750</link><pubDate>Fri, 25 May 2007 18:50:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2874750</guid><dc:creator>Microsoft Office SharePoint and related</dc:creator><description>&lt;p&gt;We are going the way to use more XML based content. This makes us more flexible with further ideas but&lt;/p&gt;
</description></item><item><title>A common business need: Generating server-side documents on the fly</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#4515333</link><pubDate>Wed, 22 Aug 2007 23:22:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4515333</guid><dc:creator>Erika Ehrli</dc:creator><description>&lt;p&gt;I gathered a list of common Open XML questions related to programmability: What are the Open XML File&lt;/p&gt;
</description></item><item><title>Adding content to Word "content control" programmatically</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#4799473</link><pubDate>Fri, 07 Sep 2007 06:18:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4799473</guid><dc:creator>All About SharePoint - S.S. Ahmed - MVP Microsoft SharePoint &lt;img src="http://farm2.static.flickr.com/1154/1235050388_eab1d5c4e9.jpg?v=0" alt="S.S. Ahmed - MVP Microsoft SharePoint" border="0" /&gt;</dc:creator><description>&lt;p&gt;Category: Word programming Level: Advance Here is a small tip on how to add data to Word content control&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#5390616</link><pubDate>Wed, 10 Oct 2007 12:53:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5390616</guid><dc:creator>Constantin</dc:creator><description>&lt;p&gt;Is there a possibility to select all the cc with a specific name? ... throw select i mean make them somehow visible .. showing their titles or highlighted .. this being done programmatically.&lt;/p&gt;
</description></item><item><title>RE: Open XML Stuff</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#5932123</link><pubDate>Tue, 06 Nov 2007 12:30:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5932123</guid><dc:creator>Timothy J. Winters</dc:creator><description>&lt;p&gt;Hi Erika,&lt;/p&gt;
&lt;p&gt;I'm (very) new to Open XML (and programming altogther)and have been playing around with it for a couple of days now. I've been trying to link an external XML file to a word document, but am having some issues in doing this.&lt;/p&gt;
&lt;p&gt;Basically, i'll describe exactly what i'm doing and perhaps you can point me in the right direction:&lt;/p&gt;
&lt;p&gt;1) Create a new word 2007 document&lt;/p&gt;
&lt;p&gt;2) Add 3 plain text content controls from the developer tab&lt;/p&gt;
&lt;p&gt;3) Save the document in docx format&lt;/p&gt;
&lt;p&gt;4) Launch VBA Editor&lt;/p&gt;
&lt;p&gt;5) Enter the following code to add a custom XML part and load an XML document:&lt;/p&gt;
&lt;p&gt;ActiveDocument.CustomXMLParts.Add&lt;/p&gt;
&lt;p&gt;ActiveDocument.CustomXMLParts(3).Load (&amp;quot;c:\T\Data.xml&amp;quot;)&lt;/p&gt;
&lt;p&gt;NB - The XML file looks like this:&lt;/p&gt;
&lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;Customer&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;CompanyName&amp;gt;Timothy Winters&amp;lt;/CompanyName&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;Location&amp;gt;Springfield&amp;lt;/Location&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;Phone&amp;gt;02476144524&amp;lt;/Phone&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/Customer&amp;gt;&lt;/p&gt;
&lt;p&gt;6) Bind the data in the XML nodes to the (previously created) content controls:&lt;/p&gt;
&lt;p&gt;Dim strXPath1 As String&lt;/p&gt;
&lt;p&gt;strXPath1 = &amp;quot;/Customer/CompanyName&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(1).XMLMapping.SetMapping strXPath1&lt;/p&gt;
&lt;p&gt;Dim strXPath1 As String&lt;/p&gt;
&lt;p&gt;strXPath1 = &amp;quot;/Customer/Location&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(2).XMLMapping.SetMapping strXPath1&lt;/p&gt;
&lt;p&gt;Dim strXPath1 As String&lt;/p&gt;
&lt;p&gt;strXPath1 = &amp;quot;/Customer/Phone&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(3).XMLMapping.SetMapping strXPath1&lt;/p&gt;
&lt;p&gt;7) Click 'save' in VBA Editor.&lt;/p&gt;
&lt;p&gt;8) No changes in the content controls!!!!&lt;/p&gt;
&lt;p&gt;Where am I going wrong, Erika? :( I know it's something silly, but I can't quite put my finger on it at the moment!&lt;/p&gt;
&lt;p&gt;I'm unsure as to whether I enter the code in steps 5 &amp;nbsp;6 into the 'Immediate' window or in the 'Code' window. Do I enter step 5 first and then save? Or do I enter both sets of code at once and then save? :s&lt;/p&gt;
&lt;p&gt;Some assistance at grassroots level is desperately needed... :)&lt;/p&gt;
&lt;p&gt;Thanks in advance, Erika!&lt;/p&gt;
&lt;p&gt;PS You're doing a great job!!!!&lt;/p&gt;
&lt;p&gt;Timothy.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#5932178</link><pubDate>Tue, 06 Nov 2007 12:34:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5932178</guid><dc:creator>Timothy J. Winters</dc:creator><description>&lt;p&gt;PS In step 6 above, I entered the code incorrectly on the post. It should have read:&lt;/p&gt;
&lt;p&gt;Dim strXPath1 As String&lt;/p&gt;
&lt;p&gt;strXPath1 = &amp;quot;/Customer/CompanyName&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(1).XMLMapping.SetMapping strXPath1&lt;/p&gt;
&lt;p&gt;Dim strXPath2 As String&lt;/p&gt;
&lt;p&gt;strXPath1 = &amp;quot;/Customer/Location&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(2).XMLMapping.SetMapping strXPath2&lt;/p&gt;
&lt;p&gt;Dim strXPath3 As String&lt;/p&gt;
&lt;p&gt;strXPath1 = &amp;quot;/Customer/Phone&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(3).XMLMapping.SetMapping strXPath3&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#5932207</link><pubDate>Tue, 06 Nov 2007 12:36:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5932207</guid><dc:creator>Timothy J. Winters</dc:creator><description>&lt;p&gt;Pardon me again... i'm having a bad day! My last post should have read:&lt;/p&gt;
&lt;p&gt;Dim strXPath1 As String&lt;/p&gt;
&lt;p&gt;strXPath1 = &amp;quot;/Customer/CompanyName&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(1).XMLMapping.SetMapping strXPath1&lt;/p&gt;
&lt;p&gt;Dim strXPath2 As String&lt;/p&gt;
&lt;p&gt;strXPath2 = &amp;quot;/Customer/Location&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(2).XMLMapping.SetMapping strXPath2&lt;/p&gt;
&lt;p&gt;Dim strXPath3 As String&lt;/p&gt;
&lt;p&gt;strXPath3 = &amp;quot;/Customer/Phone&amp;quot;&lt;/p&gt;
&lt;p&gt;ActiveDocument.ContentControls(3).XMLMapping.SetMapping strXPath3&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#5964283</link><pubDate>Wed, 07 Nov 2007 20:00:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5964283</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;There are a couple of little checks that can be done here:&lt;/p&gt;
&lt;p&gt;1) how many custom XML parts have you got loaded?&lt;/p&gt;
&lt;p&gt;?ActiveDocument.CustomXMLParts.count&lt;/p&gt;
&lt;p&gt;Word will just keep adding CustomXMLParts to a document every time you save, so you may find you have loads of bad data that does not map loaded. If this is the case check the XML in each part:&lt;/p&gt;
&lt;p&gt;?ActiveDocument.CustomXMLParts(4).xml&lt;/p&gt;
&lt;p&gt;and where your (bad) data is loaded delete it.&lt;/p&gt;
&lt;p&gt;ActiveDocument.CustomXMLParts(4).delete&lt;/p&gt;
&lt;p&gt;2) has your XML loaded?&lt;/p&gt;
&lt;p&gt;activedocument.ContentControls(2).XMLMapping&lt;/p&gt;
&lt;p&gt;Will return True or False dependent on the sucess of the mapping; perhaps a msgbox as a result of false might help. Note: there appear to be very few error messages if mapping fails, the process appears to continue and map what can be mapped.&lt;/p&gt;
&lt;p&gt;3) finally you have run the VBA haven't you?&lt;/p&gt;
&lt;p&gt;PS I added the mapping on document_open, including a global variable recording the number of the new customXMLpart.On document_close the new customXMLpart is deleted. This is of particular use where the document is used as a template.&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#6525016</link><pubDate>Mon, 26 Nov 2007 06:11:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6525016</guid><dc:creator>Kathryn</dc:creator><description>&lt;p&gt;Once the data is in a data content control, say a simple rich text content control, how do we insert that into another part of the document. That is, how can I resuse text entered by the user within the same document?&lt;/p&gt;
&lt;p&gt;Kathryn&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#7343394</link><pubDate>Thu, 31 Jan 2008 10:11:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7343394</guid><dc:creator>Frode</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I've a case where i need to convert all dynamic content in a Word 2007 document to static text. Any ideas how and where to do this?&lt;/p&gt;
&lt;p&gt;The requirement is equivalent to what happens when you use the Save As function in Word 2007 and stores the document as a an old Word 97/2003 document, but it has to be done on the server side. &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Frode&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#7365938</link><pubDate>Fri, 01 Feb 2008 06:51:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7365938</guid><dc:creator>Ray</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have a question whether everyone can help me with this VBA. I'm fairly new to this program but the company wants me to develop something for them. In word 2007, under the insert tab, there is a quick part section where the user can control its document property. I am developing a similar function to the document property, I've created a text box and a button where the user can put the text in the text box and hit the button. Once they hit the button, at the moment the content control is creating along with the string that is written inside the text box. However, when I change text from the text box, I have no control to change the content control that has already been written on the sheet. Below is the code to add the content control and the string. Any idea how to update all the content control that has been written on the sheet to the new text inserted in the text box?&lt;/p&gt;
&lt;p&gt;Dim editdocadd As String&lt;/p&gt;
&lt;p&gt;Dim rngTemp As Range&lt;/p&gt;
&lt;p&gt;Dim objRange As Range&lt;/p&gt;
&lt;p&gt;Dim objCustomPart As CustomXMLPart&lt;/p&gt;
&lt;p&gt;Dim objCustomControl As ContentControl&lt;/p&gt;
&lt;p&gt;Dim objCustomNode As CustomXMLNode&lt;/p&gt;
&lt;p&gt; Private Sub Callprop(ByVal control As IRibbonControl)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'ActiveDocument.BuiltInDocumentProperties(&amp;quot;Title&amp;quot;).Value = editdocadd&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'ActiveDocument.BuiltInDocumentProperties editdocadd&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Set objCustomPart = ActiveDocument.CustomXMLParts.Add&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;objCustomPart.LoadXML (&amp;quot;&amp;lt;evans&amp;gt;&amp;lt;author&amp;gt;Rayz&amp;lt;/author&amp;gt;&amp;quot; &amp;amp; _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;&amp;lt;title&amp;gt;&amp;quot; + editdocadd + &amp;quot;&amp;lt;/title&amp;gt;&amp;lt;/evans&amp;gt;&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ActiveDocument.Range.InsertParagraphAfter&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Set objRange = ActiveDocument.Paragraphs(1).Range&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Set objCustomNode = objCustomPart.SelectSingleNode _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(&amp;quot;/evans/title&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Set objCustomControl = ActiveDocument.ContentControls _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.Add(wdContentControlText, objRange)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;objCustomControl.XMLMapping.SetMappingByNode objCustomNode&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;End Sub&lt;/p&gt;
&lt;p&gt;Any help would be much appreciated. &lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ray&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#7688849</link><pubDate>Thu, 14 Feb 2008 12:05:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7688849</guid><dc:creator>Ron Gregory</dc:creator><description>&lt;p&gt;You can download the &amp;quot;Word 2007 Content Control Kit&amp;quot; which allows you to map Content Controls to XML without using VBA.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#7793578</link><pubDate>Tue, 19 Feb 2008 16:51:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7793578</guid><dc:creator>HA</dc:creator><description>&lt;p&gt;Hi Erika,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;We have written word letter tempaltes in 2003 but we are having trouble with variuos versions of word on the client machines.&lt;/p&gt;
&lt;p&gt;At this point we are thinking of generating letter templates that are independent of versions any help will be highly appreciated.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#7888648</link><pubDate>Mon, 25 Feb 2008 08:29:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7888648</guid><dc:creator>Ray</dc:creator><description>&lt;p&gt;Hi Ron, &lt;/p&gt;
&lt;p&gt;Thanks for the suggestion to download Content Control Kit. I have downloaded and used it. I seems to be working fine. However, I can't find anywhere to add the xml that we have editted with using content control manually to the word document. Is it possible to add extra button like it is provided under document property (i.e. if we add property name on xml and it shows on the word document when we open it. At the moment, there is no menu to add another property name instead we have to copy it manually.) Any suggestion how to add a button that we can add the additional property name?&lt;/p&gt;
&lt;p&gt;Thanks in advance :)&lt;/p&gt;
&lt;p&gt;Ray&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#8136136</link><pubDate>Mon, 10 Mar 2008 21:43:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8136136</guid><dc:creator>Warraich</dc:creator><description>&lt;p&gt;Nice article, I am looking something opposite of this. I have the data/contents in MS Word 2007 files and I want to save them to the database and also want to display them on the web site. Any commnets?&lt;/p&gt;
&lt;p&gt;atiqw@yahoo.com&lt;/p&gt;
&lt;p&gt;thanks much.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#8466003</link><pubDate>Wed, 07 May 2008 18:02:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8466003</guid><dc:creator>henry2003</dc:creator><description>&lt;p&gt;can you help me with my question&lt;/p&gt;
&lt;p&gt;is there a way that when saving a document &amp;nbsp;under Save As the name &amp;nbsp;the document gets saved under is automatically pulled in from pre defined field in the document property&lt;/p&gt;
&lt;p&gt;this would save me a step of having to retype the name and date of the document when I use the Save As &lt;/p&gt;
</description></item><item><title>Erika Ehrli : Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#8580376</link><pubDate>Sun, 08 Jun 2008 03:21:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8580376</guid><dc:creator>Relationship Compatibility</dc:creator><description>&lt;p&gt;Last week I had a chance to write some interesting code samples. I missed coding a lot, and I felt a little rusty after working in different projects. But I had a lot of fun and I want to share with you one of the samples I wrote: A simple ASP.NET 2.&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#8884734</link><pubDate>Thu, 21 Aug 2008 16:01:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8884734</guid><dc:creator>Mohan Kumar K</dc:creator><description>&lt;p&gt;Hi Erika,&lt;/p&gt;
&lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;Customer&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;CompanyName&amp;gt;Alfreds Futterkiste&amp;lt;/CompanyName&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;ContactName&amp;gt;Maria Anders&amp;lt;/ContactName&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;ContactTitle&amp;gt;Sales Representative&amp;lt;/ContactTitle&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;Phone&amp;gt;030-0074321&amp;lt;/Phone&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/Customer&amp;gt; &lt;/p&gt;
&lt;p&gt;In the above code we mapped the plain text to the content controls? Is there anyway to input the image on the sample xml file?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Mohan&lt;/p&gt;
</description></item><item><title>re: Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1</title><link>http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx#9903074</link><pubDate>Mon, 05 Oct 2009 08:36:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9903074</guid><dc:creator>ahsan</dc:creator><description>&lt;p&gt;plz write some code in C# or vb.net for this article thanks.&lt;/p&gt;
</description></item></channel></rss>