Root Property

Microsoft Excel Visual Basic

Root Property

       

Returns the root DiagramNode object which the root diagram node belongs.

expression.Root

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

Example

The following example creates an organization chart and adds child nodes to the root diagram node.

Sub AddChildNodesToRoot()

    Dim nodDiagram As DiagramNode
    Dim shDiagram As Shape
    Dim intCount As Integer

    Set shDiagram = ActiveSheet.Shapes.AddDiagram _
        (Type:=msoDiagramOrgChart, Left:=10, Top:=15, _
        Width:=400, Height:=475)

    ' Add the first node to the diagram.
    shDiagram.DiagramNode.Children.AddNode

    ' Establish the first node as the root.
    Set nodDiagram = shDiagram.DiagramNode.Root

    ' Add three modes to the diagram.
    For intCount = 1 To 3
        nodDiagram.Children.AddNode
    Next intCount

End Sub