FormatCondition.Borders 屬性 (Excel)

傳回代表條件化格式邊界的 Borders 集合。

語法

運算式。框線

運算式 代表 FormatCondition 物件的變數。

註解

FormatCondition 傳回的 Borders 集合使用條件化格式側常數 xlLeft、xlRight、xlTop 和 xlBottom。

請勿搭配此集合使用 xlEdgeLeft、 xlEdgeRight、 xlEdgeTop、 xlEdgeBottom、 xlInsideHorizontal 或 xlInsideVertical 。 這些常數適用於 Range.Borders。 當您存取 LineStyle 或 Weight 等屬性時,搭配 FormatCondition.Borders 使用 xlEdge 索引可能會導致執行階段錯誤 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 支援與意見反應。