Class Border (Word VBA)

The class Border represents a border of an object. The Border object is a member of the Borders collection.

Set

To use a Border class variable it first needs to be instantiated, for example

Dim brd as Border
Set brd = Selection.Borders(Index:=1)

The following procedures can be used to set variables of type Border: Borders.Item, Cell.Borders, Cells.Borders, Column.Borders, Columns.Borders, ConditionalStyle.Borders, Font.Borders, Frame.Borders, HTMLDivision.Borders, InlineShape.Borders, Paragraph.Borders, ParagraphFormat.Borders, Paragraphs.Borders, Range.Borders, Row.Borders, Rows.Borders, Section.Borders, Selection.Borders, Style.Borders, Table.Borders and TableStyle.Borders

For Each

Here is an example of processing the Border items in a collection.

Dim brd As Border
For Each brd In Selection.Borders
	    If brd.Inside = True Then brd.LineStyle = wdLineStyleSingle 
Next brd

Themes

The following procedures in this class have been grouped together and are described on a separate theme page

Enable with its procedures Borders.Enable, Borders.EnableFirstPageInSection and Borders.EnableOtherPagesInSection

Properties

ArtStyle returns or sets the graphical page-border design for a document.

Selection.Borders(1).ArtStyle = wdArtApples

ArtWidth returns or sets the width (in points) of the specified graphical page border.

Selection.Borders(1).ArtWidth =

Color returns or sets the 24-bit color for the specified Border object.

Selection.Borders(1).Color = RGB(0,0,255)'blue

ColorIndex returns or sets the color for the specified border or font object.

Selection.Borders(1).ColorIndex = wdAuto

Inside true if an inside border can be applied to the specified object.

Dim booInside As Boolean
booInside = Selection.Borders(1).Inside

LineStyle returns or sets the border line style for the specified object.

Selection.Borders(1).LineStyle = wdLineStyleDashDot

LineWidth returns or sets the line width of an object's border.

Selection.Borders(1).LineWidth = wdLineWidth025pt

Parent returns an object that represents the parent object of the specified Border object.

Dim objParent As Object
Set objParent = Selection.Borders(1).Parent

Visible true if the specified object is visible.

Selection.Borders(1).Visible = True

Borders.AlwaysInFront true if page borders are displayed in front of the document text.

Selection.Borders.AlwaysInFront = True

Borders.Count returns the number of items in the Borders collection.

Dim lngCount As Long
lngCount = Selection.Borders.Count

Borders.DistanceFrom returns or sets a value that indicates whether the specified page border is measured from the edge of the page or from the text it surrounds.

Selection.Borders.DistanceFrom = wdBorderDistanceFromPageEdge

Borders.DistanceFromBottom returns or sets the space (in points) between the text and the bottom border.

Selection.Borders.DistanceFromBottom =

Borders.DistanceFromLeft returns or sets the space (in points) between the text and the left border.

Selection.Borders.DistanceFromLeft =

Borders.DistanceFromRight returns or sets the space (in points) between the right edge of the text and the right border.

Selection.Borders.DistanceFromRight =

Borders.DistanceFromTop returns or sets the space (in points) between the text and the top border.

Selection.Borders.DistanceFromTop =

Borders.HasHorizontal true if a horizontal border can be applied to the object.

Dim booHasHorizontal As Boolean
booHasHorizontal = Selection.Borders.HasHorizontal

Borders.HasVertical true if a vertical border can be applied to the specified object.

Dim booHasVertical As Boolean
booHasVertical = Selection.Borders.HasVertical

Borders.InsideColor returns or sets the 24-bit color of the inside borders.

Selection.Borders.InsideColor = RGB(0,0,255)'blue

Borders.InsideColorIndex returns or sets the color of the inside borders.

Selection.Borders.InsideColorIndex = wdAuto

Borders.InsideLineStyle returns or sets the inside border for the specified object.

Selection.Borders.InsideLineStyle = wdLineStyleDashDot

Borders.InsideLineWidth returns or sets the line width of the inside border of an object.

Selection.Borders.InsideLineWidth = wdLineWidth025pt

Borders.JoinBorders true if vertical borders at the edges of paragraphs and tables are removed so that the horizontal borders can connect to the page border.

Selection.Borders.JoinBorders = True

Borders.OutsideColor returns or sets the 24-bit color of the outside borders.

Selection.Borders.OutsideColor = RGB(0,0,255)'blue

Borders.OutsideColorIndex returns or sets the color of the outside borders.

Selection.Borders.OutsideColorIndex = wdAuto

Borders.OutsideLineStyle returns or sets the outside border for the specified object.

Selection.Borders.OutsideLineStyle = wdLineStyleDashDot

Borders.OutsideLineWidth returns or sets the line width of the outside border of an object.

Selection.Borders.OutsideLineWidth = wdLineWidth025pt

Borders.Parent returns an object that represents the parent object of the specified Borders collection.

Dim objParent As Object
Set objParent = Selection.Borders.Parent

Borders.Shadow true if the specified border is formatted as shadowed.

Selection.Borders.Shadow = True

Borders.SurroundFooter true if a page border encompasses the document footer.

Selection.Borders.SurroundFooter = True

Borders.SurroundHeader true if a page border encompasses the document header.

Selection.Borders.SurroundHeader = True