ColorIndex 属性

       

返回或设置指定边框或字体的颜色。WdColorIndex,可读写。

expression.ColorIndex

expression   必需。该表达式返回“应用于”列表中的一个对象。

说明

wdByAuthor 常量对边框和字体对象无效。

示例

本示例更改活动文档首段的文字颜色。

ActiveDocument.Paragraphs(1).Range.Font.ColorIndex = wdGreen

本示例将所选文本的格式设置为红色。

Selection.Font.ColorIndex = wdRed

本示例为第一个表格的每个单元格添加红虚线边框。

Dim borderLoop As Border

If ActiveDocument.Tables.Count >= 1 Then
    For Each borderLoop In ActiveDocument.Tables(1).Borders
        With borderLoop
            .ColorIndex = wdRed
            .LineStyle = wdLineStyleDashDot
            .LineWidth = wdLineWidth075pt
        End With
    Next borderLoop
End If