Borders Property

Microsoft Word Visual Basic

Borders Property

       

Returns a Borders collection that represents all the borders for the specified object.

expression.Borders

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks

For information about returning a single member of a collection, see Returning an Object from a Collection.

Example

This example applies inside and outside borders to the first table in the active document.

Set myTable = ActiveDocument.Tables(1)
With myTable.Borders
    .InsideLineStyle = wdLineStyleSingle
    .OutsideLineStyle = wdLineStyleDouble
End With

This example applies a border around the first character in the selection. If nothing is selected, the border is applied to the first character after the insertion point.

Selection.Characters(1).Borders.Enable = True

This example applies a bottom border below all centered paragraphs in the active document.

For Each para In ActiveDocument.Paragraphs
    If para.Alignment = wdAlignParagraphCenter Then
        para.Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
        para.Borders(wdBorderBottom).LineWidth = wdLineWidth300pt
    End If
Next para

This example adds a border around all the pages in the current section.

For Each aBorder In Selection.Sections(1).Borders
    aBorder.ArtStyle = wdArtBasicBlackDots
    aBorder.ArtWidth = 6
Next aBorder