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.ObjectOptional XlLineStyle. The line style for the border. Can be one of the following XlLineStyle constants:
xlContinuousdefault
xlDash
xlDashDot
xlDashDotDot
xlDot
xlDouble
xlLineStlyeNone
xlSlantDashDot
xlLineStlyeNone
Weight
Type: Microsoft.Office.Interop.Excel.XlBorderWeightOptional XlBorderWeight. The border weight. Can be one of the following XlBorderWeight constants:
xlHairline
xlMedium
xlThick
xlThindefault
ColorIndex
Type: Microsoft.Office.Interop.Excel.XlColorIndexOptional 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.ObjectOptional 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.