向单元格区域添加边框,并设置该边框的 Color、LineStyle 和 Weight 属性。Variant 类型。
expression.BorderAround(LineStyle, Weight, ColorIndex, Color)
expression 必需。该表达式返回“应用于”列表中的对象之一。
LineStyle XlLineStyle 类型,可选。边框线条的样式。
XlLineStyle 可为以下 XlLineStyle 常量之一。 |
xlContinuous default |
xlDash |
xlDashDot |
xlDashDotDot |
xlDot |
xlDouble |
xlLineStlyeNone |
xlSlantDashDot |
xlLineStlyeNone |
Weight XlBorderWeight 类型,可选。边框的粗细。
XlBorderWeight 可为以下 XlBorderWeight 常量之一。 |
xlHairline |
xlMedium |
xlThick |
xlThin default |
ColorIndex XlColorIndex 类型,可选。边框颜色,作为当前颜色调色板的索引或作为 XlColorIndex 常量。
XlColorIndex 可为以下 XlColorIndex 常量之一。 |
xlColorIndexAutomatic default |
xlColorIndexNone |
Color Variant 类型,可选。以 RGB 值指定边框的颜色。
必须指定 ColorIndex 或者 Color,但不能同时指定这两者。
可指定 LineStyle 或 Weight,但不能同时指定这两者。如果未指定任何参数,Microsoft Excel 将使用默认的线条样式和粗细。
本方法只是给出整个区域的外框,而不填充该区域。如果要设置所有单元格的边框,就必须设置 Borders 集合的 Color、LineStyle 和 Weight 属性。删除边框线,要对区域中所有单元格设置 LineStyle 属性为 xlLineStyleNone。
本示例向工作表 Sheet1 上的区域 A1:D4 添加红色的粗外框。
Worksheets("Sheet1").Range("A1:D4").BorderAround _
ColorIndex:=3, Weight:=xlThick