Border Object

Description

Represents the border of an object.

Accessors

Most bordered objects (all except the Range and Style objects) have a border that is treated as a single entity, regardless of how many sides it has. The entire border must be accessed at once. Use the Border property to return the border of this kind of object. The following example activates the chart sheet named "Chart1," places a dashed border around the chart area for the active chart and a dotted border around the plot area.


Charts("chart1").Activate
With ActiveChart
    .ChartArea.Border.LineStyle = xlDash
    .PlotArea.Border.LineStyle = xlDot
End With

The appearance of line-like objects (such as lines, error bars, and arcs) is controlled by setting properties of the Border object for the line-like object. Setting the Border property for a line, for example, changes the way the line itself is drawn. The following example activates the worksheet named "Sheet1" and then sets the line style and color for a line on the active sheet.


Worksheets("sheet1").Activate
With ActiveSheet.Lines(1).Border
    .LineStyle = xlDashDot
    .Color = RGB(255, 0, 0)
End With

Range and Style objects have four discrete borders—left, right, top, and bottom—which can be accessed individually or as a group. Use the Borders method with an argument to return a single Border object. The following example sets the bottom border of cells A1:G1 to a double line.


Worksheets("Sheet1").Range("a1:g1"). _
    Borders(xlBottom).LineStyle = xlDouble

To change all four borders of a Range or Style object, use the Borders method with no arguments to access the entire Borders collection at once.

Properties

Application Property, Color Property, ColorIndex Property, Creator Property, LineStyle Property, Parent Property, Weight Property.