Table of contents
TOC
Collapse the table of content
Expand the table of content

Application.CreateComparisonReport Method (Project)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Creates a comparison report between two versions of a project.

Syntax

expression. CreateComparisonReport( ** Filename, ** TaskTable, ** ResourceTable, ** Items, ** Columns, ** ShowLegend )

expression An expression that returns an Application object.

Parameters

NameRequired/OptionalData TypeDescription
FilenameOptionalStringFull path and name of the project file to compare.
TaskTableOptionalStringName of the table to use for comparison in a task view.
ResourceTableOptionalStringName of the table to use for comparison in a resource view.
ItemsOptionalPjCompareVersionItemsSpecifies the type of items to compare.
ColumnsOptionalPjCompareVersionColumnsSpecifies whether to show only column data, only column differences, or both differences and data.
ShowLegendOptionalVariantIf True, shows the legend in the comparison report.

Return Value

Boolean

Remarks

The CreateComparisonReport method compares task or resource information, but not assignment information.

Example

The following example demonstrate how to create a comparison report. The code first checks that a project is currently open, and then checks that either tasks or resources are in the project. The comparison report is based on cost tables, filtered for only changed task or resource cost information, with columns that display only the differences between tasks or resources. Finally, the comparison report is saved with a file name based on the current (first) project.

Sub ComparisonReport () 
    If Projects.Count = 0 Then 
        MsgBox "You must have at least one active project open before you can compare projects.", _ 
            vbInformation 
        Exit Sub 
    ElseIf ActiveProject.Tasks.Count = 0 Then 
        If ActiveProject.ResourceCount = 0 Then 
            MsgBox "There are no task or resources in the current project. " &; vbCrLf _ 
            &; "Open a project with either tasks or resources before creating a comparison report.", _ 
            vbInformation 
            Exit Sub 
        End If 
    End If 

    ' Get the name of the project to use for saving the comparison report. 
    Dim currentProject As Project 
    Set currentProject = ActiveProject 

    Dim previousVersion As String 
    previousVersion = "[full path to .mpp file to compare with the active project.]" 

    CreateComparisonReport FileName:=previousVersion, _ 
    TaskTable:="Cost", _ 
    ResourceTable:="Cost", _ 
    Items:=pjCompareVersionItemsChangedItems, _ 
    Columns:=pjCompareVersionColumnsDifferencesOnly, _ 
    Showlegend:=True 

    ' Save the comparison report based upon the name of the first project. 
    Dim comparisonReport As Project 
    Set comparisonReport = ActiveProject 
    ActiveProject.SaveAs currentProject &; "_Compared.mpp" 
End Sub
© 2018 Microsoft