Application.CreateComparisonReport メソッド (Project)

2 つのバージョンのプロジェクトの比較レポートを作成します。

構文

CreateComparisonReport( _FileName_, _TaskTable_, _ResourceTable_, _Items_, _Columns_, _ShowLegend_ )

Application オブジェクトを返す式。

パラメーター

名前 必須 / オプション データ型 説明
FileName 省略可能 String 比較するプロジェクト ファイルの完全パスと名前を指定します。
TaskTable 省略可能 String タスク ビューで比較に使用するテーブルの名前を指定します。
ResourceTable 省略可能 String リソース ビューで比較に使用するテーブルの名前を指定します。
Items 省略可能 PjCompareVersionItems 比較するアイテムの種類を指定します。
Columns 省略可能 PjCompareVersionColumns 列データのみを表示するか、列の差異のみを表示するか、差異とデータの両方を表示するかを指定します。
ShowLegend 省略可能 バリアント型 (Variant) 場合は True 、比較レポートの凡例が表示されます。

戻り値

ブール型 (Boolean)

注釈

CreateComparisonReport メソッドは、タスクまたはリソースについてがない割り当て情報を比較します。

次の使用例は、比較レポートを作成する方法を示します。 このコードでは、まず現在プロジェクトが開かれていることを確認し、次に、プロジェクトにタスクまたはリソースが含まれていることを確認します。 この比較レポートはコスト テーブルに基づいており、変更されたタスクまたはリソースのコスト情報のみが表示されるようフィルターが適用されており、タスクまたはリソースの差異のみを表示する列があります。 最後に、比較レポートは現在の (最初の) プロジェクトに基づくファイル名で保存されます。

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

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。