ConditionalStyle object (Word)

Represents special formatting applied to specified areas of a table when the selected table is formatted with a specified table style.

Remarks

Use the Condition method of the TableStyle object to return a ConditionalStyle object. The Shading property can be used to apply shading to specified areas of a table. This example selects the first table in the active document and applies shading to alternate rows and columns. This example assumes that there is a table in the active document and that it is formatted using the Table Grid style.

Sub ApplyConditionalStyle() 
 With ActiveDocument 
 .Tables(1).Select 
 With .Styles("Table Grid").Table 
 .Condition(wdOddColumnBanding).Shading _ 
 .BackgroundPatternColor = wdColorGray10 
 .Condition(wdOddRowBanding).Shading _ 
 .BackgroundPatternColor = wdColorGray10 
 End With 
 End With 
End Sub

Use the Borders property to apply borders to specified areas of a table. This example selects the first table in the active document and applies borders to the first and last row and first column. This example assumes that there is a table in the active document and that it is formatted using the Table Grid style.

Sub ApplyTableBorders() 
 With ActiveDocument 
 .Tables(1).Select 
 With .Styles("Table Grid").Table 
 .Condition(wdFirstRow).Borders(wdBorderBottom) _ 
 .LineStyle = wdLineStyleDouble 
 .Condition(wdFirstColumn).Borders(wdBorderRight) _ 
 .LineStyle = wdLineStyleDouble 
 .Condition(wdLastRow).Borders(wdBorderTop) _ 
 .LineStyle = wdLineStyleDouble 
 End With 
 End With 
End Sub

See also

Word Object Model Reference

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.