Excel返回或设置边框、字体或内部颜色

0表示无色

ColorIndex 属性 (Excel Graph)

返回或设置边框、字体或内部颜色,如中下表所示。 颜色可指定为当前调色板中颜色的索引值,也可指定为下列 XlColorIndex 常量之一:xlColorIndexAutomatic 或 xlColorIndexNone。 读/写 Variant

语法

expression.ColorIndex

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

注释

Object说明
Border边框的颜色。
Font字体颜色。
Interior填充的内部颜色。 将 ColorIndex 设置为 xlColorIndexNone,以指定你不想进行内部填充。 将 ColorIndex 设置为 xlColorIndexAutomatic,以指定自动填充(适用于图形对象)。

此属性指定一种颜色作为调色板的索引。 下图展示了默认调色板中的颜色索引值。

颜色

示例

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

以下示例设置数值轴主要网格线的颜色。

VB

With myChart.Axes(xlValue) 
 If .HasMajorGridlines Then 
 'Set color to blue 
 .MajorGridlines.Border.ColorIndex = 5 
 End If 
End With

以下示例将图表区内部颜色设置为红色,边框颜色设置为蓝色。

VB

With myChart.ChartArea 
 .Interior.ColorIndex = 3 
 .Border.ColorIndex = 5 
End With

参考链接

ColorIndex 属性 (Excel Graph) | Microsoft Learnhttps://learn.microsoft.com/zh-cn/office/vba/api/excel.colorindexExcel VBA Interior.ColorIndex 色彩列表 - Alice Sun - 博客园https://www.cnblogs.com/alicesunBlog/articles/2861089.html

特此记录

anlog

2026年5月20日

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值