LastChild Property

Microsoft PowerPoint Visual Basic

expression.LastChild

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

Example

The following example creates a new diagram and identifies the last child diagram node.

Sub LastChildNodeHello()

    Dim shpDiagram As Shape
    Dim dgnNode As DiagramNode
    Dim dgnLast As DiagramNode
    Dim intNodes As Integer

    'Add org chart to first slide and first child node
    Set shpDiagram = ActivePresentation.Slides(1).Shapes.AddDiagram _
        (Type:=msoDiagramOrgChart, Left:=10, Top:=15, _
        Width:=400, Height:=475)
    Set dgnNode = shpDiagram.DiagramNode.Children.AddNode

    'Add three additional nodes
    For intNodes = 1 To 3
        dgnNode.Children.AddNode
    Next intNodes

    'Enter text into last child node
    Set dgnLast = dgnNode.Children.LastChild
    dgnLast.Shape.TextFrame.TextRange.Text = "Here I am!"

End Sub