Project) (Shapes.AddShape 方法

將指定的 AutoShape 類型的圖形新增到報表,並傳回代表新圖形的 Shape 物件。

語法

expression。 AddShape (類型,左,頂端,寬度,高度)

expression 代表 Shapes 物件的變數。

參數

名稱 必要/選用 資料類型 描述
Type 必要 MsoAutoShapeType 指定要建立的快取圖案的類型。
Left 必要 Single 快取圖案左邊緣的位置, 以點為單位。
Top 必要 Single 快取圖案上邊緣的位置, 以點為單位。
Width 必要 Single 快取圖案的寬度, 單位點。
Height 必要 Single 快取圖案的高度, 單位點。
Type 必要 MSOAUTOSHAPETYPE
Left 必要 FLOAT
Top 必要 FLOAT
Width 必要 FLOAT
Height 必要 FLOAT
名稱 必要/選用 資料類型 描述

傳回值

圖形

註解

若要變更快取圖案的類型,請設定 AutoShapeType 屬性。

範例

下列範例會建立包含兩個雲朵圖形的報表,然後將第二個雲朵圖形變更為黃色對話氣球。

Sub TestShapes()
    Dim shapeReport As Report
    Dim reportName As String
    
    ' Add a report.
    reportName = "Shape report"
    Set shapeReport = ActiveProject.Reports.Add(reportName)

    ' Add two clouds.
    Dim cloudShape1 As shape
    Dim cloudShape2 As shape
    Set cloudShape1 = shapeReport.Shapes.AddShape(msoShapeCloud, 20, 20, 100, 60)
    Set cloudShape2 = shapeReport.Shapes.AddShape(msoShapeCloud, 100, 200, 60, 100)
    
    ' Change the blue cloud to a yellow speech balloon.
    cloudShape2.AutoShapeType = msoShapeBalloon
    cloudShape2.Fill.ForeColor.RGB = &H80FFFF
End Sub

另請參閱

圖形物件圖形物件AutoShapeType 屬性Office) (MsoAutoShapeType 列舉

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。