AddDiagram Method

Returns a Shape object that represents a newly created diagram in a document.

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

expression Required. An expression that returns a Shapes object.

MsoDiagramType

MsoDiagramType can be one of these MsoDiagramType constants.
msoDiagramCycle Shows a process with a continuous cycle.
msoDiagramMixed Not used with this method.
msoDiagramOrgChart Shows hierarchical relationships.
msoDiagramPyramid Shows foundation-based relationships.
msoDiagramRadial Shows relationships of a core element.
msoDiagramTarget Shows steps toward a goal.
msoDiagramVenn Shows areas of overlap between elements.

Left Required Single. The position, measured in points, of the left edge of the diagram's bounding box relative to the anchor.

Top   Required Single. The position, measured in points, of the top edge of the diagram's bounding box relative to the anchor.

Width Required Single. The width, measured in points, of the diagram's bounding box.

Height   Required Single. The height, measured in points, of the diagram's bounding box.

Anchor   Optional Variant. A Range object that represents the text to which the diagram is bound. If Anchor is specified, the anchor is positioned at the beginning of the first paragraph in the anchoring range. If this argument is omitted, the anchoring range is selected automatically and the diagram is positioned relative to the top and left edges of the page.

Example

This example adds a pyramid chart to the current document.

Sub CreatePyramidDiagram()
    Dim dgnNode As DiagramNode
    Dim shpDiagram As Shape
    Dim intCount As Integer

    'Add pyramid diagram to current document
    Set shpDiagram = ThisDocument.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
        dgnNode.AddNode
    Next intCount

End Sub

Applies to | Shapes Collection Object