none
Table styles & Microsoft Word 2007 WordML compatibility RRS feed

  • Question

  • In Word 2003 I can define a custom table style and apply this style to a table using the Styles pane. If I save a document as WordML (Word2003 xml), Word 2003 creates the following xml markup:

     

    <w:tbl> 
      <w:tblPr>
        <w:pStyle @w:val='MyTableStyle' /><br/>
    

    In Microsoft Word 2007 new AutoFormat  feature for tables was introduced, and Word 2007 is no longer generates the "w:tblPr/w:pStyle" elements pair for tables neither generates any similar attribute/element instead, so I'm unable to detect what style was applied to my table. In addition, table styles are no longer visible on the Styles taskpane.

    How could I force Word 2007 to generate the w:pStyle element for tables?

    • Moved by Cindy Meister MVPModerator Tuesday, October 25, 2011 1:59 PM Open xml file format question (From:General Office Development)
    Tuesday, October 25, 2011 12:57 PM

Answers

  • Hi Dmitry

    If you look more closely you'll see that the Table Style is saved in the WordProcessingML file under "Styles". But saving in the older file format saves the formatting directly in the table, rather than linking the style to it.

    As I said, you can't make 2007 become 2003. It's a newer version and behaves differently.

    As you see, Word 2007 does generate an element with the table style. And if you create a new, named Table Style you'll see the table style name. The definition will be in the style.xml Part of the Open XML zip package.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Wednesday, November 2, 2011 7:33 AM
    Tuesday, October 25, 2011 2:22 PM
    Moderator

All replies

  • Hi Dmitry

    This forum probably isn't the best one for this question. On MSDN the Open XML SDK might be the better forum as that deals with the Open XML vocabularies for the various applications. I can move the discussion there, if you wish...

    Starting in Word 2007 the Open XML file format replaced WordProcessingML and some changes were also made in how Table and List styles are perceived. You can't make Word 2007 work like Word 2003, although you could save in the older file format (Word 2003 XML) if you wish.

    But that won't change how the UI works. Table styles are still there and do still work pretty much as before, but they won't appear in the Styles task pane. Instead, you need to go to the Table Tools/Design tab and use the Table Styles gallery.

    New in Office 2007 are the concepts of "themes" and "designs". What's offered to the user in the way of color combinations, fonts and styles is based on the chosen "theme" and "design". (Look at the far left in the Page Layout tab of the Ribbon.) What's offered under Table styles is affected by these settings and, if you select things from the "theme" categories (such as colors) these will change if a different theme is selected, or a color in the them palette is changed.

    So the way a Table style is defined in Word 2007 (and 2010) is different than in Word 2003. And this is also reflected in the Open XML file.

    If you want to learn more about themes and such I recommend the book "Advanced Office Documents" by Stephanie Krieger, published by Microsoft Press.


    Cindy Meister, VSTO/Word MVP
    Tuesday, October 25, 2011 1:27 PM
    Moderator
  • Thank you very much for your answer and move the question to a more appropriate forum if you please
    Tuesday, October 25, 2011 1:32 PM
  • Hm.

    I've just created and saved a document with a table formatted with the "Table Styles" tool as a docx file, then changed extension to .zip, unpacked it and opened the document.xml file.

    Here is a code snippet (Word 2007):

    <w:tbl><w:tblPr><w:tblStyle w:val="a4"/>

    And the correspondent one from the same file saved in 2003/xml format:

    <w:tbl>

      <w:tblPr>

           <w:tblW w:w="0" w:type="auto"/><!-- no w:tblStyle element -->

     

    Tuesday, October 25, 2011 1:52 PM
  • Hi Dmitry

    If you look more closely you'll see that the Table Style is saved in the WordProcessingML file under "Styles". But saving in the older file format saves the formatting directly in the table, rather than linking the style to it.

    As I said, you can't make 2007 become 2003. It's a newer version and behaves differently.

    As you see, Word 2007 does generate an element with the table style. And if you create a new, named Table Style you'll see the table style name. The definition will be in the style.xml Part of the Open XML zip package.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Wednesday, November 2, 2011 7:33 AM
    Tuesday, October 25, 2011 2:22 PM
    Moderator