Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 2.05 KB

Word.ConditionalStyle.md

File metadata and controls

65 lines (47 loc) · 2.05 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
ConditionalStyle object (Word)
vbawd10.chm1389
vbawd10.chm1389
Word.ConditionalStyle
2380494e-09e9-8494-a93c-8bbaf621aad1
06/08/2017
medium

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

[!includeSupport and feedback]