PrevNode Method

Microsoft Word Visual Basic

PrevNode Method

       

Returns a DiagramNode object that represents the previous diagram node in a collection of diagram nodes.

expression.PrevNode

expression   Required. An expression that returns a DiagramNode object.

Remarks

Use the NextNode method to return the next DiagramNode object in a collection of diagram nodes.

Example

This example adds 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 = ThisDocument.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 preceding the second
    'diagram node and add three child nodes
    Set dgnPrev = dgnRoot.Children.Item(2).PrevNode

    For intCount = 1 To 3
        dgnPrev.Children.AddNode
    Next intCount

End Sub