Reports.Add method (Project)

Adds a custom report to the Reports collection.

Syntax

expression.Add (Name)

expression A variable that represents a 'Reports' object.

Parameters

Name Required/Optional Data type Description
Name Required String The name of the report.
Name Required String

Return value

Report

The custom report object that is added.

Remarks

The new report is empty; it does not contain any shapes such as tables or charts. To add shapes to the report, you can use methods in the Shapes object such as AddChart and AddTable.

Examples

The following example adds an empty report named Report 1, and displays the report.

Sub AddReport()
    ActiveProject.Reports.Add "Report 1"
End Sub

To delete a report, you must change to a different view, as in the following example:

Sub DeleteAReport()
    Dim reportName As String
    
    reportName = "Report 1"
    
    If ActiveProject.Reports.IsPresent(reportName) Then
        ' To delete the active report, change to another view.
        ViewApplyEx Name:="&Gantt Chart"
        
        ActiveProject.Reports(reportName).Delete
    Else
        MsgBox Prompt:="No report name: " & reportName, Title:="Report delete error"
    End If
End Sub

See also

Reports Object Report Object Shapes

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.