返回一个 DiagramNode 对象,该对象代表父节点的第一个子节点。
expression.FirstChild
expression 必需。该表达式返回“应用于”列表中的对象之一。
本示例向当前的工作表添加一个组织结构图图表,添加三个节点,并将第一个和最后一个节点指定为变量。
Sub FirstChild()
Dim shpDiagram As Shape
Dim dgnRoot As DiagramNode
Dim dgnFirstChild As DiagramNode
Dim dgnLastChild As DiagramNode
Dim intCount As Integer
'Add organizational chart diagram to the current document
Set shpDiagram = ActiveSheet.Shapes.AddDiagram( _
Type:=msoDiagramOrgChart, Left:=10, _
Top:=15, Width:=400, Height:=475)
'Add the first node to the diagram
Set dgnRoot = shpDiagram.DiagramNode.Children.AddNode
'Add three child nodes
For intCount = 1 To 3
dgnRoot.Children.AddNode
Next intCount
'Assign the first and last child nodes to variables
Set dgnFirstChild = dgnRoot.Children.FirstChild
Set dgnLastChild = dgnRoot.Children.LastChild
End Sub