共用方式為


Application.CompareProjectVersions 方法 (Project)

會顯示 [比較專案版本] 對話方塊,來比較兩個專案的版本。

語法

expressionCompareProjectVersions

表達 會傳回 Application 物件的運算式。

傳回值

布林值

註解

CompareProjectVersions 方法相當於在功能區上的 [ 專案] 索引標籤的 [ 報表] 群組中的 [ 比較專案] 命令。 若要以程式設計方式控制 (例如是否有顯示差異欄) 的專案比較功能,請使用 CreateComparisonReport 方法。

範例

下列範例會檢查專案是否開啟在呼叫 CompareProjectVersions 方法之前。 如果專案開啟時,請將程式碼會檢查是否有任務或資源的專案中呼叫此方法之前。

Sub CompareVersions () 
    If Projects.Count = 0 Then 
        MsgBox "You must have at least one project open before you can compare projects." 
    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 
 
    CompareProjectVersions 
End Sub

支援和意見反應

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