CloneNode Method

Microsoft PowerPoint Visual Basic

Show All

CloneNode Method

       

Clones a diagram node.

expression.CloneNode(CopyChildren, TargetNode, Pos)

expression Required. An expression that returns one of the objects in the Applies To list.

CopyChildren Required Boolean. True to include the diagram node's children.

TargetNode Optional DiagramNode object. An expression that returns a DiagramNode that will be the source for the cloned diagram node.

Pos Optional MsoRelativeNodePosition. If TargetNode is specified, where the node will be added, relative to TargetNode.

MsoRelativeNodePosition can be one of these MsoRelativeNodePosition constants.
msoAfterLastSibling
msoAfterNode default
msoBeforeFirstSibling
msoBeforeNode

Example

The following example creates a diagram and clones the newest-created node.

Sub CloneANode()

    Dim dgnNode As DiagramNode
    Dim shpDiagram As Shape
    Dim intNodes As Integer

    'Adds cycle diagram and first child node
    Set shpDiagram = ActivePresentation.Slides(1).Shapes.AddDiagram _
        (Type:=msoDiagramCycle, Left:=10, Top:=15, _
        Width:=400, Height:=475)
    Set dgnNode = shpDiagram.DiagramNode.Children.AddNode

    'Adds three additional nodes to diagram
    For intNodes = 1 To 3
        dgnNode.AddNode
    Next intNodes

    'Automatically formats the diagram
    dgnNode.Diagram.AutoFormat = msoTrue

    'Clones the first child node without cloning associated child nodes
    dgnNode.CloneNode CopyChildren:=False

End Sub