Borders.Enable property (Word)

Returns or sets border formatting for the specified object. Read/write Long.

Syntax

expression. Enable

expression A variable that represents a 'Borders' collection.

Remarks

The Enable property returns True or wdUndefined if border formatting is applied to all or part of the specified object. Can be set to True, False, or a WdLineStyle constant.

The Enable property applies to all borders for the specified object. True sets the line style to the default line style and sets the line width to the default line width. The default line style and line width can be set using the DefaultBorderLineWidth and DefaultBorderLineStyle properties.

To remove all the borders from an object, set the Enable property to False, as shown in the following example.

ActiveDocument.Tables(1).Borders.Enable = False

To remove or apply a single border, use Borders (index), where index is a WdBorderType constant, to return a single border, and then set the LineStyle property. The following example removes the bottom border from rngTemp.

Dim rngTemp 
 
rngTemp.Borders(wdBorderBottom).LineStyle = wdLineStyleNone 

Example

This example removes all borders from the first cell in table one.

If ActiveDocument.Tables.Count >= 1 Then 
 ActiveDocument.Tables(1).Cell(1, 1).Borders.Enable = False 
End If

This example applies a dashed border around the first paragraph in the selection.

Options.DefaultBorderLineWidth = wdLineWidth025pt 
Selection.Paragraphs(1).Borders.Enable = _ 
 wdLineStyleDashSmallGap

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

See also

Borders Collection Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.