全部显示

AddDiagram 方法

       

创建图表。返回一个 Shape 对象,该对象代表新建的图表。

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

expression   必需。该表达式返回“应用于”列表中的对象之一。

Type   MsoDiagramType 类型,必需。图表的类型。

Left   Single 类型,必需。相对于工作表的左上角,以磅为单位给出图表左上角的位置。

Top   Single 类型,必需。相对于工作表的左上角,以磅为单位给出图表左上角顶端的位置。

Width   Single 类型,必需。以磅为单位给出图表的宽度。

Height   Single 类型,必需。以磅为单位给出图表的高度。

示例

本示例向活动工作表添加棱锥图。

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
        dgnNode.AddNode
    Next intCount

End Sub