DistanceFrom Property

Microsoft Word Visual Basic

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. Read/write WdBorderDistanceFrom.

WdBorderDistanceFrom can be one of these WdBorderDistanceFrom constants.
wdBorderDistanceFromPageEdge
wdBorderDistanceFromText

expression.DistanceFrom

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

Example

This example adds a single border around each page in section one in the active document and then sets the distance between each border and the corresponding edge of the page.

Dim borderLoop As Border

With ActiveDocument.Sections(1)
    For Each borderLoop In .Borders
        borderLoop.LineStyle = wdLineStyleSingle
        borderLoop.LineWidth = wdLineWidth050pt
    Next borderLoop
    With .Borders
        .DistanceFrom = wdBorderDistanceFromPageEdge
        .DistanceFromTop = 20
        .DistanceFromLeft = 22
        .DistanceFromBottom = 20
        .DistanceFromRight = 22
    End With
End With
		

This example adds a border around each page in the first section in the selection, and then it sets the distance between the text and the page border to 6 points.

Dim borderLoop As Border

With Selection.Sections(1)
    For Each borderLoop In .Borders
        borderLoop.ArtStyle = wdArtSeattle
        borderLoop.ArtWidth = 22
    Next borderLoop
    With .Borders
        .DistanceFrom = wdBorderDistanceFromText
        .DistanceFromTop = 6
        .DistanceFromLeft = 6
        .DistanceFromBottom = 6
        .DistanceFromRight = 6
    End With
End With