Condition Method

Microsoft Word Visual Basic

Show All

Condition Method

       

Returns a ConditionalStyle object that represents special style formatting for a portion of a table.

expression.Condition(ConditionCode)

expression   Required. An expression that returns one of the objects in the Applies To list.

ConditionCode  Required WdConditionCode. The are of the table to which to apply the formatting.

WdConditionCode can be one of these WdConditionCode constants.
wdEvenColumnBanding  Applies formatting to even-numbered columns.
wdEvenRowBanding  Applies formatting to even-numbered rows.
wdFirstColumn  Applies formatting to the first column in a table.
wdFirstRow  Applies formatting to the first row in a table.
wdLastColumn  Applies formatting to the last column in a table.
wdLastRow  Applies formatting to the last row  in a table.
wdNECell  Applies formatting to the last cell in the first row.
wdNWCell  Applies formatting to the first cell in the first row.
wdOddColumnBanding  Applies formatting to odd-numbered columns.
wdOddRowBanding  Applies formatting to odd-numbered rows.
wdSECell  Applies formatting to the last cell in the table.
wdSWCell  Applies formatting to first cell in the last row of the table.

Example

This example selects the first table in the active document and adds a 20 percent shading to odd-numbered columns.

Sub TableStylesTest()
    With ActiveDocument

        'Select the table to which the conditional
        'formatting will apply
        .Tables(1).Select

        'Specify the conditional formatting
        .Styles("Table Grid").Table _
            .Condition(wdOddColumnBanding).Shading _
            .BackgroundPatternColor = wdColorGray20
    End With
End Sub