AddNode Method

Microsoft Excel Visual Basic

Show All

AddNode Method

       

AddNode method as it applies to the DiagramNodeChildren object.

Creates a diagram node. Returns a DiagramNode object that represents the new node.

expression.AddNode(Index, nodeType)

expression   Required. An expression that returns a DiagramNodeChildren object

Index  Optional Variant. The position of the node.

nodeType  Optional MsoDiagramNodeType. The type of node.

MsoDiagramNodeType can be one of these MsoDiagramNodeType constants.
msoDiagramAssistant
msoDiagramNode default

AddNode method as it applies to the DiagramNode object.

Creates a diagram node. Returns a DiagramNode object that represents the new node. DiagramNode object.

expression.AddNode(pos, nodeType)

expression   Required. An expression that returns a DiagramNode object.

pos  Optional MsoRelativeNodePosition. Where the node will be added, relative to another node.

MsoRelativeNodePosition can be one of these MsoRelativeNodePosition constants.
msoAfterLastSibling
msoAfterNode default
msoBeforeFirstSibling
msoBeforeNode

nodeType  Optional MsoDiagramNodeType. The type of node.

MsoDiagramNodeType can be one of these MsoDiagramNodeType constants.
msoDiagramAssistant
msoDiagramNode default

Example

This example adds a node to a diagram node on the active sheet.

Sub DiagramNodeOBJ()

        Dim nodDiagNode As DiagramNode
        Dim shDiagram As Shape

        Set shDiagram = ActiveSheet.Shapes.AddDiagram _
            (Type:=msoDiagramOrgChart, _
            Left:=10, _
            Top:=15, _
            Width:=400, _
            Height:=475)

        Set nodDiagNode = shDiagram.DiagramNode

        'Add a root node to the diagram.
        nodDiagNode.Children.AddNode

End Sub