expression.SwapNode(TargetNode)
expression Required. An expression that returns a DiagramNode object.
TargetNode Required DiagramNode object. The node with which to swap.
Pos Optional MsoRelativeNodePosition. The position of the node relative to the node with which it is being swapped.
MsoRelativeNodePosition can be one of the following MsoRelativeNodePosition constants.
msoAfterLastSibling |
msoAfterNode |
msoBeforeFirstSibling |
msoBeforeNode |
Example
The following example swaps two nodes in a newly created diagram.
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