SwapNode Method

Microsoft PowerPoint Visual Basic

expression.SwapNode(TargetNode, SwapChildren)

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

TargetNode   Required DiagramNode object. The target diagram node.

SwapChildren   Optional Boolean. True (default) if all child diagram nodes are moved along with their corresponding target or source diagram nodes. False to swap just the target and source diagram nodes, inheriting the other's child diagram nodes.

Example

The following example swaps the first and third nodes in a newly-created diagram.

Sub SwapTwoNodes()

    Dim dgnNode As DiagramNode
    Dim shpDiagram As Shape
    Dim intNodes As Integer

    'Adds radial diagram and first node
    Set shpDiagram = ActivePresentation.Slides(1).Shapes _
        .AddDiagram(Type:=msoDiagramRadial, Left:=10, _
        Top:=15, Width:=400, Height:=475)
    Set dgnNode = shpDiagram.DiagramNode.Children.AddNode

    'Adds three additional nodes
    For intNodes = 1 To 3
        dgnNode.Children.AddNode
    Next intNodes

    'Swaps the first and the third nodes
    dgnNode.Children.Item(1).SwapNode _
        TargetNode:=dgnNode.Children.Item(3)

End Sub