共用方式為


ShapeRange.Apply 方法 (專案)

對一個形狀範圍套用格式化,該範圍的格式資訊是透過 PickUp 方法複製的。

語法

表情

一個代表「ShapeRange」物件的變數。

傳回值

Nothing

範例

以下範例建立三個圓柱形,將第一個形狀染成紅色,將第二和第三個形狀加入一個形狀範圍,複製第一個形狀的格式化,然後將格式化套用到該形狀範圍內。

Sub ApplyShapeFormat()
    Dim theReport As Report
    Dim shp1 As shape
    Dim shp2 As shape
    Dim shp3 As shape
    Dim reportName As String
    Dim sRange As ShapeRange
    
    reportName = "Apply Report"
    
    Set theReport = ActiveProject.Reports.Add(reportName)
    Set shp1 = theReport.Shapes.AddShape(msoShapeCan, 10, 30, 100, 100)
    shp1.Name = "Shape 1"
    shp1.Fill.ForeColor.RGB = &H1010FF  ' Red color.
    
    ' Blue default color.
    Set shp2 = theReport.Shapes.AddShape(msoShapeCan, 30, 140, 100, 100)
    
    ' Blue default color.
    Set shp3 = theReport.Shapes.AddShape(msoShapeCan, 140, 140, 100, 100)
    
    Set sRange = theReport.Shapes.Range(Array(2, 3))
    
    theReport.Shapes("Shape 1").PickUp
    sRange.Apply
End Sub

另請參閱

ShapeRange 物件拾取方法Shape.Apply 方法

支援和意見反應

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