需要检查项目是否已签出

时间:2017-11-10 11:37:18

标签: vba sharepoint ms-project

如何检查我们是否可以签出项目。 项目存储在sharepoint中。 此代码始终打印无法结帐

Sub macro()

Dim a As Project

Shell "C:\Program Files (x86)\Microsoft Office\Office15\Winproj.exe /s https://inside.com/PWA/QWER/Project.aspx", vbNormalFocus

Sleep 3000

FileOpenEx Name:="<>\" & "ProjectNAME", ReadOnly:=True, DoNotLoadFromEnterprise:=False

Set a = Projects.Item(1)

a.Activate

If (Projects.CanCheckOut(ActiveProject.Name)) Then

    Debug.Print "Can check out the project"
Else

    Debug.Print "Cannot checkout the project"

End If

End Sub

这将非常有帮助

1 个答案:

答案 0 :(得分:0)

如果您需要在MS-Project VBA中运行代码,请使用以下代码:

Sub CheckOutProject(docCheckOut As String)

' Determine whether project can be checked out
If Projects.CanCheckOut(docCheckOut) = True Then
    Debug.Print "Can check out the project"

    ' if you want, you can check it out
    Projects.CheckOut docCheckOut
Else
    Debug.Print "Cannot checkout the project"
End If

End Sub

使用下面的Test代码对其进行测试:

Sub Test()

Dim FullPath As String

' Full Path equals the full SharePoint Path & File name (including extension)
FullPath = "http://share.Comapny.com/sites/Test123/Project%20Documentsnew/Project%20Files/Project_1.mpp"
CheckOutProject FullPath ' call the Sub

End Sub