Word 2007 ConditionalStyle 中的错误
我正在使用 Word 2007 对象模型来操作表格。 每当我读取表格样式的 ConditionalStyle
对象的 Shading
或 Borders
属性(使用 VBA 或 C#)时,它都会重置表格应用的条件样式设置为标题行、带状行和第一列,并清除所有表格级格式(边框和底纹)。
无论我是通过表的 Style
属性还是通过文档的 Style
集合访问 ConditionalStyle
,都会发生这种情况。
要重现该问题,请制作一个 Word 2007 文档,其中的表格应用了某些格式(边框或底纹),选择表格的任意部分,然后在 VBA 的立即窗口中运行以下代码:
print Selection.Tables(1).Style.Table.Condition(1).Shading.BackgroundPatternColor
该表格将按上述方式重置。
其他人可以在他们的环境中重现此问题吗? (我使用 Word 2007 SP1 和 SP2 在 Windows 7 和 Windows Server 2003 中重现了它)
有人能猜出为什么会发生这种情况吗?
任何人都可以找到读取阴影的解决方法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过在检查
ConditionalStyle
之前选择表格之外的文档部分来解决此问题; 仅当选择在表内时才会出现该错误。但我仍然不知道为什么会发生这种情况。
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.