Root 属性

       

返回根图表节点所属的根 DiagramNode 对象。

expression.Root

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

示例

下例创建一个组织结构图,并向根图表节点中添加子节点。

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