Project) (Project.CheckoutProject 方法

簽出目前處於唯讀模式的開啟專案。

語法

expressionCheckoutProject

運算式 代表 Project 物件的變數。

傳回值

Nothing

註解

如果 Project 專業版中使用中的專案處於唯讀模式,CheckoutProject.method 會簽出專案,使其處於讀取/寫入模式以進行編輯。 如果使用中的專案已簽出,Project 會顯示一個對話方塊,其中包含訊息:「此專案已在不同的電腦或 Project Web App 工作階段簽出給您」。

範例

下列範例會判斷開啟的專案是否為企業專案並已簽出。如果專案未出庫使用,範例會嘗試出庫使用專案。 如果專案已簽出給您,Project 會顯示一個對話方塊,其中顯示錯誤訊息:「此專案已在不同的電腦或 Project Web App 工作階段簽出給您。」如果專案已由其他使用者簽出,Project 會顯示一個對話方塊,其中顯示訊息:「若要簽出,DOMAIN\UserName 必須關閉其工作階段中的專案,或連絡您的系統管理員以簽入專案。」

Sub CheckOutOpenEnterpriseProjects()
    Dim openProjects As Projects
    Dim proj As Project
    
    Set openProjects = Application.Projects
    
    On Error Resume Next
    
    For Each proj In openProjects
        If Application.IsCheckedOut(proj.Name) Then
            If proj.Type = pjProjectTypeEnterpriseCheckedOut Then
                Debug.Print "'" & proj.Name & "'" & " is already checked out."
            ElseIf proj.Type = pjProjectTypeNonEnterprise Then
                Debug.Print "'" & proj.Name & "'" & " is not an enterprise project."
            End If
        Else
            ' Check out the project whether it is active or not.
            proj.CheckoutProject
            Debug.Print "Attempted to check out: '" & proj.Name & "'"
        End If
    Next proj
End Sub

另請參閱

專案物件簽入方法

Application.IsCheckedOutApplication.ProjectCheckOut

支援和意見反應

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