Borders Property

Microsoft Office Web Components Object Model

Borders Property

       

Returns a Borders collection that represents the four borders of a range of cells. Read-only.

expression.Borders

expression   Required. An expression that returns a Range object.

Example

This example adds a medium-weight green border to each cell in the range B5:C10 on Sheet1.

Sub SetBorders()
    Dim ssConstants
    Dim rngBorder
	
    Set ssConstants = Spreadsheet1.Constants
	
    ' Set a variable to the range to add the borders to.
    Set rngBorder = Spreadsheet1.Worksheets("Sheet1").Range("b5:c10")

    ' Set the border weight.
    rngBorder.Borders.Weight = ssConstants.owcLineWeightMedium
	
    ' Set the border color.
    rngBorder.Borders.Color = "green"
End Sub