边框对象 (Excel)Borders object (Excel)

由四个**Border** 对象组成的集合, 这些对象代表**Range** 对象或**Style** 对象的四个边框。A collection of four Border objects that represent the four borders of a Range object or Style object.

说明Remarks

使用 Borders 属性可返回包含所有四个边框的 Borders 集合。Use the Borders property to return the Borders collection, which contains all four borders.

只能对 RangeStyle 对象的各个边框分别设置边框属性。You can set border properties for an individual border only with Range and Style objects. 其他带边框的对象 (如误差线和系列线) 的边框被视为单个实体, 而不管它有多少条边。Other bordered objects, such as error bars and series lines, have a border that's treated as a single entity, regardless of how many sides it has. 对于这些对象,在返回边框和设置边框属性时必须将其作为一个整体处理。For these objects, you must return and set properties for the entire border as a unit. 有关详细信息,请参阅 Border 对象。For more information, see the Border object.

示例Example

下例向第一张工作表上的单元格 A1 添加双边框。The following example adds a double border to cell A1 on worksheet one.

Worksheets(1).Range("A1").Borders.LineStyle = xlDouble

使用边框(索引), 其中_索引_标识边框, 返回单个边框对象。Use Borders (index), where index identifies the border, to return a single Border object. 下例将单元格区域 A1:G1 的底部边框颜色设置为红色。The following example sets the color of the bottom border of cells A1:G1 to red.

Worksheets("Sheet1").Range("A1:G1"). _ 
 Borders(xlEdgeBottom).Color = RGB(255, 0, 0)

_索引_可以是下列**XlBordersIndex** 常量之一: xlDiagonalDownxlDiagonalUpxlEdgeBottomxlEdgeLeftxlEdgeRightxlEdgeTopxlInsideHorizontal、或xlInsideVerticalIndex can be one of the following XlBordersIndex constants: xlDiagonalDown, xlDiagonalUp, xlEdgeBottom, xlEdgeLeft, xlEdgeRight, xlEdgeTop, xlInsideHorizontal, or xlInsideVertical.

属性Properties

另请参阅See also

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.