ReplaceNode 方法

       

用源图示节点替换目标图示节点。目标图示节点将被删除,而源图示节点(包括其所有子节点)将移动到目标图示节点所在的位置。

expression.ReplaceNode(TargetNode)

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

TargetNode  必选。DiagramNode 对象。要替换的图示节点。

示例

以下示例用新建图示的第二个节点替换最后一个图示节点。

Sub ReplaceLastNode()

    Dim dgnNode As DiagramNode
    Dim shpRadial As Shape
    Dim intNodes As Integer

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

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

    'Displays the number of nodes in the diagram
    MsgBox "The number of nodes in the diagram : " & _
         dgnNode.Diagram.Nodes.Count

    'Second node replaces the last node.
    dgnNode.Diagram.Nodes(2).ReplaceNode _
        TargetNode:=dgnNode.Diagram.Nodes(4)

    'Node count is three because the replaced node was deleted
    MsgBox "The number of nodes in the diagram : " & _
        dgnNode.Diagram.Nodes.Count

End Sub