none
How to keep reports template created in word 2003 in word 2010 after xml being stripped off in word 2010 RRS feed

  • Question

  • I have been using word 2003 to create templates using custom xml parts.  But now I have upgraded to word 2010, and I can`t see the custom xml parts, nor the values are being replaced using datasource.  Is there a possibility to use all those templates created so that we don`t need to create them again.  Is there a tool, or program that can be used such that our users don`t have to re-create the existing reports?



    Sha_woop

    Tuesday, January 22, 2013 11:25 AM

Answers

  • Hi Sha_woop

    Yes, what you describe is a common enough problem. If you want an "off the shelf" kind of solution I suggest you contact Microsoft paid support, quote the KB article number I referenced at them, tell them you built a solution on technology they've removed and that you need a way to convert these templates to *.docx files with content controls.

    Otherwise, you're going to need to do this yourself and it will take quite a bit of work. It wouldn't be so bad if these were *.doc files as I believe in that case the nodes would be retained. But because these are *.xml files the information is being stripped. (I understand why these are *.xml files - so that you can write the data into them directly.)

    Probably what I'd do in your situation, if the paid support route isn't an option, would be to open the files in Word 2003 (or an early release of Word 2007). Remove the attached schema. Replace the XML Nodes with a bookmark containing the node name and save as a *.doc or *.docx. (If the Compatibility Pack is installed, you can save as *.docx and this will save you time/work). This step allows you to retain the target location for the data from your database. (Note: you can't change the *.xml files to work with content controls because they post-date the file format and aren't supported by it.)

    Now you can either

    1. Change your code to use Open XML and write to the bookmarks instead of to the XML nodes

    2. Working with Open XML, create a tool to replace the bookmarks with content controls and change your code to write to the content controls instead of the XML nodes

    3. As (2), but map the content controls to a Custom XML Part so that you can link the content controls to that and write the data to the custom xml part instead of the XML nodes or content controls

    4. Change the bookmarks to content controls by hand, in Word 2010, then change your code to work with the content controls as in (2)

    5. As (4), but also create a Custom XML Part, map the content controls to that, and change your code as in (3)

    The path you take is purely a matter of personal preference. You'll need to research content controls, custom xml parts and Open XML. Open XML is what Word 2007 and later use to work with files the way you currently do with the Word 2003 xml. You'll find some links in the article I referenced to give you a start.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Sha_woop Wednesday, January 23, 2013 7:43 AM
    • Unmarked as answer by Sha_woop Wednesday, January 23, 2013 7:43 AM
    • Marked as answer by Sha_woop Wednesday, January 23, 2013 7:43 AM
    Tuesday, January 22, 2013 8:24 PM
    Moderator

All replies

  • Custom XML Parts weren't available in Word 2003 so I assume you've mistaken the technical term...

    Do you mean that a schema was attached to the template in Word 2003 and, from that schema, nodes were tragged to the document surface, generating XML tags? Is your problem basically what's described in this article:
      http://support.microsoft.com/kb/2445062

    This article also makes some suggestions for alternative approaches.

    If your basic business scenario is that data is being placed in the custom XML NODES, similar to a mail merge while the file is closed, then I suggest you consider replacing them with content controls mapped to a custom XML part (or not) and write the data to the controls (or the custom xml part) before delivering the solution to the user.

    The Word Open XML file format and the Open XML SDK can help with the programming.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, January 22, 2013 11:32 AM
    Moderator
  • One problem that I will have in this case is due to the fact that the users create the template themselves.  How can I solve the latter?

    Actually the scenario is as follows:

    We have a database application that stores data that we want to report in Microsoft Word.

    Suppose all information of my customers is stored on a database system and I am now requested to create hundreds of word letters, reports that will be sent to my customers. These letters have the same content but different customer name, customer address, etc.

    I have been using word 2003 xml file to creating document template and using c# and .Net, sql as database to replace the content of this template.

    Now the users are no more able to see those xml tags in the xml file and we need to upgrade to 2010 so that but we don`t want users to recreate those templates... 

    Please guide which is best method to do that so far.


    Sha_woop

    Tuesday, January 22, 2013 12:13 PM
  • Hi Sha_woop

    Yes, what you describe is a common enough problem. If you want an "off the shelf" kind of solution I suggest you contact Microsoft paid support, quote the KB article number I referenced at them, tell them you built a solution on technology they've removed and that you need a way to convert these templates to *.docx files with content controls.

    Otherwise, you're going to need to do this yourself and it will take quite a bit of work. It wouldn't be so bad if these were *.doc files as I believe in that case the nodes would be retained. But because these are *.xml files the information is being stripped. (I understand why these are *.xml files - so that you can write the data into them directly.)

    Probably what I'd do in your situation, if the paid support route isn't an option, would be to open the files in Word 2003 (or an early release of Word 2007). Remove the attached schema. Replace the XML Nodes with a bookmark containing the node name and save as a *.doc or *.docx. (If the Compatibility Pack is installed, you can save as *.docx and this will save you time/work). This step allows you to retain the target location for the data from your database. (Note: you can't change the *.xml files to work with content controls because they post-date the file format and aren't supported by it.)

    Now you can either

    1. Change your code to use Open XML and write to the bookmarks instead of to the XML nodes

    2. Working with Open XML, create a tool to replace the bookmarks with content controls and change your code to write to the content controls instead of the XML nodes

    3. As (2), but map the content controls to a Custom XML Part so that you can link the content controls to that and write the data to the custom xml part instead of the XML nodes or content controls

    4. Change the bookmarks to content controls by hand, in Word 2010, then change your code to work with the content controls as in (2)

    5. As (4), but also create a Custom XML Part, map the content controls to that, and change your code as in (3)

    The path you take is purely a matter of personal preference. You'll need to research content controls, custom xml parts and Open XML. Open XML is what Word 2007 and later use to work with files the way you currently do with the Word 2003 xml. You'll find some links in the article I referenced to give you a start.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Sha_woop Wednesday, January 23, 2013 7:43 AM
    • Unmarked as answer by Sha_woop Wednesday, January 23, 2013 7:43 AM
    • Marked as answer by Sha_woop Wednesday, January 23, 2013 7:43 AM
    Tuesday, January 22, 2013 8:24 PM
    Moderator