Application.ApplyReportLayoutTemplate method (Project)

Applies the specified report template to the active report.

Syntax

expression. ApplyReportLayoutTemplate (TemplateId)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
TemplateId Optional PjReportLayoutTemplateId Specifies the kind of report; can be one of the following constants: pjReportLayoutComparison, pjReportLayoutTitleAndChart, pjReportLayoutTitleAndTable, or pjReportLayoutTitleOnly.
TemplateId Optional PJREPORTLAYOUTTEMPLATEID

Return value

Boolean

Remarks

For an existing report, the ApplyReportLayoutTemplate method adds the specified report elements on top of other shapes in the report. For example, if the built-in Task Cost Overview report is active, the ApplyReportLayoutTemplate pjReportLayoutTitleAndChart statement adds a new text box with the report title and a new default chart to the report.

Example

The following example creates a report that contains a title text box and a basic table, and then vertically centers text in the table cells.

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

See also

Application Object

Report Object PjReportLayoutTemplateId Enumeration

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.