CloneNode Method [Excel 2003 VBA Language Reference]
Clones a diagram node. Returns a DiagramNode object representing the cloned node.
expression.CloneNode(copyChildren, pTargetNode, pos)
expression Required. An expression that returns one of the objects in the Applies To list.
copyChildren Required Boolean. True to clone the diagram nodes children as well.
pTargetNode Required DiagramNode object. An expression that returns a DiagramNode object that represents the node where the new node will be placed.
MsoRelativeNodePosition
MsoRelativeNodePosition can be one of these MsoRelativeNodePosition constants. |
msoAfterLastSibling |
msoAfterNodedefault |
msoBeforeFirstSibling |
msoBeforeNode |
Example
The following example creates a diagram and clones the newest-created node.
Sub CloneANode()
Dim nodRoot As DiagramNode
Dim shpDiagram As Shape
Dim nodFourthNode As DiagramNode
Dim nodDuplicate As DiagramNode
Dim intCount As Integer
Set shpDiagram = ActiveSheet.Shapes.AddDiagram( _
Type:=msoDiagramOrgChart, Left:=10, _
Top:=15, Width:=400, Height:=475)
Set nodRoot = shpDiagram.DiagramNode.Children.AddNode
' Add subordinate nodes to the root node
For intCount = 1 To 4
nodRoot.Children.AddNode
Next
Set nodFourthNode = nodRoot.Children.Item(4)
'Clone the most recently created child node
Set nodDuplicate = nodRoot.Children.Item(1).CloneNode(copyChildren:=True, _
pTargetNode:=nodFourthNode, pos:=msoAfterNode)
End Sub
Applies to | DiagramNode Object