Etudes for Microsoft Word Programmers. Appendix.

Information on this page is from Microsoft MSDN

Border (Word 2003)

Object Border

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

Border objects cannot be added to the Borders collection. The number of members in the Borders collection is finite and varies depending on the type of object. For example, a table has six elements in the Borders collection, whereas a paragraph has four.

Using the Border Object

Use Borders(index), where index identifies the border, to return a single Border object. Index can be one of the following WdBorderType constants: wdBorderBottom, wdBorderDiagonalDown, wdBorderDiagonalUp, wdBorderHorizontal, wdBorderLeft, wdBorderRight, wdBorderTop, or wdBorderVertical. Use the LineStyle property to apply a border line to a Border object. The following example applies a double-line border below the first paragraph in the active document.

With ActiveDocument.Paragraphs(1).Borders(wdBorderBottom)
     .LineStyle = wdLineStyleDouble
     .LineWidth = wdLineWidth025pt
 End With

Border element on the "Formatting" Toolbar

"Borders" control on the "Formatting" toolbar looks like this.

Applying any toolbar button effects in frame around selected object. Borders collection of the selected object is used.

Borders collection elements could be changed from the VBA code. If you select a paragraph and execute the following AhBorderTest procedure, then a paragraph  will be surrounded by a frame which consists of different line types.

' AhBordersTest
Sub AhBordersTest ()
    Selection.Borders.Enable = True
    Selection.Borders(wdBorderTop).LineStyle = wdLineStyleSingleWavy
    Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleDashLargeGap
    Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleDouble
    Selection.Borders(wdBorderRight).LineStyle = wdLineStyleSingle
End Sub

Here is a result of AhBordersTest procedure execution:

"Borders and Shading" Dialog

"Borders and Shading" has three tabs - "Borders", "Page Border" and "Shading".

Tab "Borders" look like this:

Pressing "Options" button allows user to define the distance between border and text using "Border and Shading Options" dialog.

Border Object Properties

Border object properties are described in the following table.





Read/write WdPageBorderArt

Returns or sets the graphical page-border design for a document. Enumeration WdPageBorderArt contains 164 constants. Could be applyed to the documenr page only.


Read/write Long

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


WdColor константа

Returns or sets the 24-bit color for the specified object.


Read/write WdColorIndex

Returns or sets the color for the specified border or font object.

The wdByAuthor constant is not valid for border object.


Read-only Boolean

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


Read/write WdLineStyle

Returns or sets the border line style for the specified object.

Setting the LineStyle property for a range that refers to individual characters or words applies a character border.

Setting the LineStyle property for a paragraph or range of paragraphs applies a paragraph border. Use the InsideLineStyle property to apply a border between consecutive paragraphs.

Setting the LineStyle property for a section applies a page border around the pages in the section.



WdLineWidth константа или wdUndefined

Returns or sets the line width of an object's border. Returns a WdLineWidth constant or wdUndefined if the object either has no borders or has borders with more than one line width.

If the specified line width isn't available for the border's line style, this property generates an error. To determine the line widths available for a particular line style, see the Borders and Shading dialog box (Format menu).


Read/write Boolean

True if the specified object is visible.

Enumeration WdLineStyle

Enumeration WdLineStyle defines the line style.

Constant Value Constant Value
wdLineStyleDashDot 5 wdLineStyleSingle 1
wdLineStyleDashDotDot 6 wdLineStyleSingleWavy 18
wdLineStyleDashDotStroked 20 wdLineStyleThickThinLargeGap 16
wdLineStyleDashLargeGap 4 wdLineStyleThickThinMedGap 13
wdLineStyleDashSmallGap 3 wdLineStyleThickThinSmallGap 10
wdLineStyleDot 2 wdLineStyleThinThickLargeGap 15
wdLineStyleDouble 7 wdLineStyleThinThickMedGap 12
wdLineStyleDoubleWavy 19 wdLineStyleThinThickSmallGap 9
wdLineStyleEmboss3D 21 wdLineStyleThinThickThinLargeGap 17
wdLineStyleEngrave3D 22 wdLineStyleThinThickThinMedGap 14
wdLineStyleInset 24 wdLineStyleThinThickThinSmallGap 11
wdLineStyleNone 0 wdLineStyleTriple 8
wdLineStyleOutset 23    

Enumeration WdLineWidth

Constant Value
wdLineWidth025pt 2
wdLineWidth050pt 4
wdLineWidth075pt 6
wdLineWidth100pt 8
wdLineWidth150pt 12
wdLineWidth225pt 18
wdLineWidth300pt 24
wdLineWidth450pt 36
wdLineWidth600pt 48



Etudes for Microsoft Word Programmers. Appendix. Object Border.

Unless otherwise noted, all materials on this site are
© 2000-2009 Evgeny Akhundzhanov, All Rights Reserved Worldwide
Microsoft is in no way affiliated with, nor offers endorsement of, this site. | E-mail the Author