ReplaceNode 方法

       

用源图表节点替换目标图表节点。目标图表节点被删除,源图表节点(包括其任意子节点)将移至目标图表节点所在的位置。

expression.ReplaceNode(pTargetNode)

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

pTargetNode   DiagramNode 对象类型,必需。将被替换的目标图表节点。

示例

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

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