ConditionalStyle Object

ConditionalStyle
Multiple objects

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

Using the ConditionalStyle object

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

Properties | Application Property | Borders Property | BottomPadding Property | Creator Property | Font Property | LeftPadding Property | ParagraphFormat Property | Parent Property | RightPadding Property | Shading Property | TopPadding Property

Parent Objects

Child Objects | Borders Object | Font Object | ParagraphFormat Object | Shading Object