Range.BorderAround Method

Adds a border to a range and sets the Color, LineStyle, and Weight properties for the new border.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function BorderAround ( _
    LineStyle As Object, _
    Weight As XlBorderWeight, _
    ColorIndex As XlColorIndex, _
    Color As Object _
) As Object
'Usage
Dim instance As Range
Dim LineStyle As Object
Dim Weight As XlBorderWeight
Dim ColorIndex As XlColorIndex
Dim Color As Object
Dim returnValue As Object

returnValue = instance.BorderAround(LineStyle, _
    Weight, ColorIndex, Color)
Object BorderAround(
    Object LineStyle,
    XlBorderWeight Weight,
    XlColorIndex ColorIndex,
    Object Color
)

Parameters

  • LineStyle
    Type: System.Object

    Optional XlLineStyle. The line style for the border. Can be one of the following XlLineStyle constants:

    • xlContinuousdefault

    • xlDash

    • xlDashDot

    • xlDashDotDot

    • xlDot

    • xlDouble

    • xlLineStlyeNone

    • xlSlantDashDot

    • xlLineStlyeNone

  • ColorIndex
    Type: Microsoft.Office.Interop.Excel.XlColorIndex

    Optional XlColorIndex. The border color, as an index into the current color palette or as an XlColorIndex constant. Can be one of the following XlColorIndex constants:

    • xlColorIndexAutomaticdefault

    • xlColorIndexNone

  • Color
    Type: System.Object

    Optional Object. The border color, as an RGB value.

Return Value

Type: System.Object

Remarks

You must specify either ColorIndex or Color, but not both.

You can specify either LineStyle or Weight, but not both. If you don't specify either argument, Microsoft Excel uses the default line style and weight.

This method outlines the entire range without filling it in. To set the borders of all the cells, you must set the Color, LineStyle, and Weight properties for the Borders collection. To clear the border, you must set the LineStyle property to xlLineStyleNone for all the cells in the range.

See Also

Reference

Range Interface

Range Members

Microsoft.Office.Interop.Excel Namespace