Word VBA教程:DistanceFrom属性

此属性返回或设置数值,该值指明指定的页面边框是从页面边框还是从环绕的文本开始度量。WdBorderDistanceFrom,可读写。

WdBorderDistanceFrom 可以是下列 WdBorderDistanceFrom 常量之一:
wdBorderDistanceFromPageEdge
wdBorderDistanceFromText

expression.DistanceFrom

expression   必需。该表达式返回“应用于”列表中的一个对象。

VBA示例

本示例为活动文档中第一节的每个页面添加单线型边框,然后设置每个边框到页面边缘的距离。


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

本示例为所选内容的第一节的每个页面添加边框,然后将文本与页面边框的距离设置为 6 磅。


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

Word VBA教程

Word VBA参考教程:目录1 Word VBA参考教程:目录2
Word VBA参考教程:目录3 Word VBA参考教程:目录4
Word VBA参考教程:目录5 Word VBA参考教程:目录6
Word VBA参考教程:目录7 Word VBA参考教程:目录8
Word VBA参考教程:目录9 Word VBA参考教程:目录10
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号