Excel) (FormatCondition.Borders 属性

返回表示条件格式边框的边 框 集合。

语法

表达式。边框

表达式 表示 FormatCondition 对象的变量。

备注

FormatCondition 返回的 Borders 集合使用条件格式侧常量 xlLeft、xlRight、xlTop 和 xlBottom。

不要对此集合使用 xlEdgeLeft、 xlEdgeRight、 xlEdgeTop、 xlEdgeBottom、 xlInsideHorizontal 或 xlInsideVertical 。 这些常量适用于 Range.Borders。 当您访问 LineStyle 或 Weight 等属性时,将 xlEdge 索引与 FormatCondition.Borders 配合使用可能会导致运行时错误 1004 (COM 错误 0x800A03EC) 。

选择受支持的条件格式侧时,可以读取或写入线 条样式、 粗细和颜色属性。 有关支持的线条样式和粗细,请参阅 FormatCondition 对象。

示例

此示例将 Sheet1 上单元格 B2 的第一个条件格式规则的底部边框设置为细红色边框。

Sub SetConditionalFormatBorder()

    With Worksheets("Sheet1").Range("B2") _
            .FormatConditions(1).Borders(xlBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = 3
    End With

End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。