LastChild 属性

       

返回一个 DiagramNode 对象,它代表父节点的最后一个子结点。

expression.LastChild

expression   必需。该表达式返回一个 DiagramNodeChildren 对象。

说明

使用 FirstChild 属性访问图表中的第一个子结点。使用 Root 属性访问图表中的父节点。

示例

本示例在当前文档中添加一个组织图表,添加三个节点,并将第一个和最后一个图表节点赋给变量。

Sub FirstChild()
    Dim shpDiagram As Shape
    Dim dgnRoot As DiagramNode
    Dim dgnFirstChild As DiagramNode
    Dim dgnLastChild 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 diagram node to the organization chart
    Set dgnRoot = shpDiagram.DiagramNode.Children.AddNode

    'Add three diagram child nodes under the first diagram node
    For intCount = 1 To 3
        dgnRoot.Children.AddNode
    Next

    'Assign the first and last child nodes to variables
    Set dgnFirstChild = dgnRoot.Children.FirstChild
    Set dgnLastChild = dgnRoot.Children.LastChild
End Sub