PrevNode Method

Microsoft Excel Visual Basic

expression.PrevNode

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

Example

This example adds additional child nodes to the first child node in a newly-created diagram.

Sub AddToPrevNode()

    Dim dgnRoot As DiagramNode
    Dim shpDiagram As Shape
    Dim dgnPrev As DiagramNode
    Dim intCount As Integer

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

    'Add first diagram node
    Set dgnRoot = shpDiagram.DiagramNode.Children.AddNode

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

    'Access the node immediately preceeding
    'the second diagram node
    Set dgnPrev = dgnRoot.Children.Item(2).PrevNode

    'Add three child nodes to the node immediately
    'preceeding the second node
    For intCount = 1 To 3
        dgnPrev.Children.AddNode
    Next intCount

End Sub