Word VBA教程:BreakForwardLink方法

在链接存在的情况下,断开指定文本框的前向链接。

expression.BreakForwardLink

expression   必需。返回 TextFrame对象的表达式。

说明

如果将此方法应用于图形,且该图形位于一串与图文框相链接的图形的中间位置,则会使链接断开,而形成两组链接的图形。但所有文本都将保留在第一组链接的图形中。

VBA示例

本示例实现的功能是:新建一个文档,在文档中添加三个前后链接的文本框,然后断开第二个文本框后面的链接。


Dim shapeTextbox1 As Shape
Dim shapeTextbox2 As Shape
Dim shapeTextbox3 As Shape
Documents.Add
Set shapeTextbox1 = ActiveDocument.Shapes.AddTextbox _
    (Orientation:=msoTextOrientationHorizontal, _
    Left:=InchesToPoints(1.5), _
    Top:=InchesToPoints(0.5), _
    Width:=InchesToPoints(1), _
    Height:=InchesToPoints(0.5))
shapeTextbox1.TextFrame.TextRange = "This is some text. " _
    & "This is some more text. This is even more text."
Set shapeTextbox2 = ActiveDocument.Shapes.AddTextbox _
    (Orientation:=msoTextOrientationHorizontal, _
    Left:=InchesToPoints(1.5), _
    Top:=InchesToPoints(1.5), _
    Width:=InchesToPoints(1), _
    Height:=InchesToPoints(0.5))
Set shapeTextbox3 = ActiveDocument.Shapes.AddTextbox _
    (Orientation:=msoTextOrientationHorizontal, _
    Left:=InchesToPoints(1.5), _
    Top:=InchesToPoints(2.5), _
    Width:=InchesToPoints(1), _
    Height:=InchesToPoints(0.5))
shapeTextbox1.TextFrame.Next = shapeTextbox2.TextFrame
shapeTextbox2.TextFrame.Next = shapeTextbox3.TextFrame
MsgBox "Textboxes 1, 2, and 3 are linked."
shapeTextbox2.TextFrame.BreakForwardLink

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号