分享

Excel VBA教程:ColorIndex属性

 笔录收藏 2015-07-22

应用于 Border对象的 ColorIndex属性。

返回或设置边框的颜色。该颜色可指定为当前调色板中颜色的编号,或下列XlColorIndex 常量之一。Variant 类型,可读写。

XlColorIndex 可为以下 XlColorIndex 常量之一。
xlColorIndexAutomatic
xlColorIndexNone

expression.ColorIndex

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

 

应用于 Borders对象的 ColorIndex属性。

返回或设置四条边框的颜色。如果四条边框不是同一种颜色,则返回 Null。该颜色可指定为当前调色板中颜色的编号,或下列XlColorIndex 常量之一。Variant 类型,可读写。

XlColorIndex 可为以下 XlColorIndex 常量之一。
xlColorIndexAutomatic
xlColorIndexNone

expression.ColorIndex

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

 

应用于 Font对象的 ColorIndex属性。

返回或设置字体的颜色。该颜色可指定为当前调色板中颜色的编号,或下列XlColorIndex 常量之一。Variant 类型,可读写。

XlColorIndex 可为以下 XlColorIndex 常量之一。
xlColorIndexAutomatic 指定自动设置颜色。
xlColorIndexNone.  

expression.ColorIndex

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

 

应用于 Interior对象的 ColorIndex属性。

返回或设置边框内部的颜色。该颜色可指定为当前调色板中颜色的编号,或下列XlColorIndex 常量之一。Variant 类型,可读写。

XlColorIndex 可为以下 XlColorIndex 常量之一。
xlColorIndexAutomatic 指定对绘图对象自动填充。
xlColorIndexNone 用于指定无内部填充。

expression.ColorIndex

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

示例

以下示例假定正在使用默认调色板。

应用 Border对象的示例。

本示例为 Chart1 中数值坐标轴的主要网格线设置了颜色。


With Charts("Chart1").Axes(xlValue)
    If .HasMajorGridlines Then
        .MajorGridlines.Border.ColorIndex = 5    'set color to blue
    End If
End With

应用 Font对象的示例。

本示例将 Sheet1 的 A1 单元格的字体颜色改为红色。


Worksheets("Sheet1").Range("A1").Font.ColorIndex = 3 

应用 Interior 和 Border对象的示例。

本示例将 Chart1 的图表区域内部颜色设为红色,将其边框的颜色设为蓝色。


With Charts("Chart1").ChartArea
    .Interior.ColorIndex = 3
    .Border.ColorIndex = 5
End With

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多