使用源图表顶点替换目标图表顶点。目标图表顶点被删除,源图表顶点(包括其子顶点)被移动到目标图表顶点的位置。
expression.ReplaceNode(TargetNode)
expression 必需。该表达式返回一个 DiagramNode 对象。
TargetNode DiagramNode 对象,必需。将要替换的图表顶点。
下列示例将新创建的图表的第四个顶点替换为第二个顶点。
Sub Replace()
Dim dgnNode As DiagramNode
Dim shpDiagram As Shape
Dim intCount As Integer
'Add pyramid diagram to current document
Set shpDiagram = ThisDocument.Shapes.AddDiagram _
(Type:=msoDiagramPyramid, Left:=10, _
Top:=15, Width:=400, Height:=475)
'Add first child node to diagram
Set dgnNode = shpDiagram.DiagramNode.Children.AddNode
'Add three more child nodes
For intCount = 1 To 3
dgnNode.AddNode
Next intCount
'Replace fourth node with the second node
dgnNode.Diagram.Nodes(2).ReplaceNode _
TargetNode:=dgnNode.Diagram.Nodes(4)
End Sub