ReplaceNode Method
Replaces a target diagram node with the source diagram node. The target diagram node is deleted, and the source diagram node, including any of its child nodes, are moved to where the target diagram node was.
expression.ReplaceNode(pTargetNode)
expression Required. An expression that returns one of the objects in the Applies To list.
pTargetNode Required DiagramNode object. The target diagram node to be replaced.
Example
The following example replaces the last diagram node of a newly-created diagram with the second node.
Sub ReplaceNode()
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
' The second node will replace the last node.
nodRoot.Children.Item(2).ReplaceNode pTargetNode:=nodRoot.Diagram.Nodes(4)
' The count will be 3 since the replaced node was deleted.
MsgBox nodRoot.Diagram.Nodes.Count
End Sub