Word VBA教程:SwapNode方法

用源图表顶点交换目标图表顶点。子图表顶点随着相应的根顶点移动。

expression.SwapNode(TargetNode)

expression   必需。该表达式返回一个DiagramNode对象。

TargetNode  DiagramNode对象,必需。要交换的顶点。

VBA示例

下列示例在新创建的图表中交换两个顶点。


Sub SwapNode()
    Dim dgnNode As DiagramNode
    Dim shpDiagram As Object
    Dim intCount As Integer
    'Add organizational chart to current document
    Set shpDiagram = ThisDocument.Shapes.AddDiagram _
        (Type:=msoDiagramOrgChart, Left:=10, _
        Top:=15, Width:=400, Height:=475)
    'Add first node to organizational chart
    Set dgnNode = shpDiagram.DiagramNode.Children.AddNode
    'Add three child nodes to the first node
    For intCount = 1 To 3
        dgnNode.Children.AddNode
    Next intCount
    'Add three child nodes to the first child node
    'of the first node
    For intCount = 1 To 3
        dgnNode.Children.Item(1).Children.AddNode
    Next intCount
    'Swap the first and third child nodes that were just created
    dgnNode.Children.Item(1).SwapNode _
        TargetNode:=dgnNode.Children.Item(3)
End Sub

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号