Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

AddDiagram Method [Excel 2003 VBA Language Reference]

Office 2003

Creates a diagram. Returns a Shape object that represents the new diagram.

expression.AddDiagram(Type, Left, Top, Width, Height)

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

MsoDiagramType can be one of these MsoDiagramType constants.
msoDiagramCycle A process diagram with a continuous cycle diagram type.
msoDiagramMixed A mixed diagram type.
msoDiagramOrgChart A hierarchical relationship diagram type.
msoDiagramPyramid A foundation based relationships diagram type.
msoDiagramRadial A diagram type showing relationships of a core element.
msoDiagramTarget A diagram type showing steps toward a goal.
msoDiagramVenn A diagram type showing areas of overlap between elements.

Left  Required Single. The position (in points) of the upper-left corner of the diagram relative to the upper-left corner of the worksheet.

Top  Required Single. The position (in points) of the upper-left top of the diagram relative to the upper-left corner of the worksheet.

Width  Required Single. The width of the diagram, in points.

Height  Required Single. The height of the diagram, in points.


This example adds a pyramid diagram to the active sheet.

Sub CreatePyramidDiagram()

    Dim dgnNode As DiagramNode
    Dim shpDiagram As Shape
    Dim intCount As Integer

    'Add pyramid diagram to current document
    Set shpDiagram = ActiveSheet.Shapes.AddDiagram _
        (Type:=msoDiagramPyramid, Left:=10, _
        Top:=15, Width:=400, Height:=475)
    'Add first diagram node child to pyramid diagram
    Set dgnNode = shpDiagram.DiagramNode.Children.AddNode

    'Add three more diagram node children to the pyramid diagram
    For intCount = 1 To 3
    Next intCount

End Sub

Applies to | Shapes Collection

© 2015 Microsoft