共用方式為


Project) (Application.ApplyReportLayoutTemplate 方法

將指定的報表範本套用至使用中報表。

語法

expressionApplyReportLayoutTemplate (TemplateId)

expression 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
TemplateId 選用 PjReportLayoutTemplateId 指定報表的種類;可以是下列其中一個常數: pjReportLayoutComparisonpjReportLayoutTitleAndChartpjReportLayoutTitleAndTablepjReportLayoutTitleOnly
TemplateId 選用 PJREPORTLAYOUTTEMPLATEID

傳回值

布林值

註解

對於現有的報表, ApplyReportLayoutTemplate 方法會在報表中的其他圖形上新增指定的報表專案。 例如,如果內建任務成本概觀報表為使用中狀態, ApplyReportLayoutTemplate pjReportLayoutTitleAndChart 語句會將含有報表標題的新文本框和新的默認圖表新增至報表。

範例

下列範例會建立包含標題文本框和基本數據表的報表,然後將表格單元格中的文字垂直置中。

Sub CreateTableReport()
    Dim theReport As Report
    Dim reportName As String
    Dim shp As Shape
    
    ' Add a report.
    reportName = "Table Report"
    Set theReport = ActiveProject.Reports.Add(reportName)
    
    ApplyReportLayoutTemplate TemplateId:=pjReportLayoutTitleAndTable
    
    For Each shp In theReport.Shapes
        If shp.HasTable Then
            shp.Select
            AlignTableCellVerticalCenter
        End If
    Next shp
End Sub

另請參閱

Application 物件

報表物件PjReportLayoutTemplateId 列舉

支援和意見反應

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