views:

66

answers:

1

I'm using the Word 2007 object model to manipulate tables. Whenever I read the Shading or Borders properties of a ConditionalStyle object for a table's style (using VBA or C#), it resets the table's applied conditional styles to Header Row, Banded Rows, and First Column, and it clears all table-level formatting (borders and shading).

This happens whether I access ConditionalStyle through the table's Style property or through the document's Style collection.

To reproduce the problem, make a Word 2007 document that has a table with some formatting (borders or shading) applied, select any part of the table, and run the following code in VBA's Immediate Window:

print Selection.Tables(1).Style.Table.Condition(1).Shading.BackgroundPatternColor

The table will be reset as described above.

Can other people reproduce this issue in their environment? (I reproduced it in Windows 7 and Windows Server 2003 using Word 2007 SP1 and SP2)

Can anyone guess why this is happening?

Can anyone find a workaround to read the Shading?

A: 

I worked around this by selecting a part of the document that is outside the table before checking the ConditionalStyle; the bug only occurs when the selection is within the table.

I still don't know why it's happening, though.

SLaks