Root Property

Microsoft Word Visual Basic

object that represents the root diagram node to which the source diagram node belongs. Read-only.

expression.Root

expression    Required. An expression that returns a DiagramNode object.

Example

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

Sub Root()
    Dim shpDiagram As Shape
    Dim dgnRoot As DiagramNode
    Dim intCount As Integer

    'Add organization chart to the current document
    Set shpDiagram = ThisDocument.Shapes.AddDiagram _
        (Type:=msoDiagramOrgChart, Left:=10, _
        Top:=15, Width:=400, Height:=475)

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

    'Assign the root diagram node to a variable
    Set dgnRoot = shpDiagram.DiagramNode.Root

    'Add three child nodes to the root node
    For intCount = 1 To 3
        dgnRoot.Children.AddNode
    Next intCount
End Sub