SwapNode 方法

       

将源图表节点与目标图表节点交换。

expression.SwapNode(pTargetNode, swapChildren)

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

pTargetNode   DiagramNode 对象类型,必需。要被替换的目标图表节点。

swapChildren   Boolean 类型,可选。要进行交换的目标节点和源节点的子节点。任意图表子节点与其相应的根节点一起移动。默认值为 True,这将交换子节点。

示例

下例将新建图表的第二个图表节点与最后一个节点交换。

Sub SwapNode()

    Dim nodRoot As DiagramNode
    Dim nodPrev As DiagramNode
    Dim shDiagram As Shape
    Dim intCount As Integer

    Set shDiagram = ActiveSheet.Shapes.AddDiagram _
        (Type:=msoDiagramRadial, Left:=10, Top:=15, _
        Width:=400, Height:=475)
    Set nodRoot = shDiagram.DiagramNode.Children.AddNode

    ' Add 3 child nodes to the root node.
    For intCount = 1 To 3
        nodRoot.Children.AddNode
    Next

    ' Swap the second node with the fourth node.
    nodRoot.Children.Item(2).SwapNode _
        pTargetNode:=nodRoot.Diagram.Nodes(4), _
        swapChildren:=True

End Sub