如何在 SharePoint 上"Check In"上传的文档?



我有VBA代码,在SharePoint上上传一个新文档。
它在SharePoint上上传新行,但它不为新项启动工作流,因为它需要"检查"。

当我手动操作时,我会点击上传,选择一个文件,填写所需的字段,然后按"检查"键;它可以添加新项并自动启动工作流。

当我用VBA做时,它会添加带有描述字段的新项,但它不会启动工作流,因为它需要"检查"

我尝试了类似于Microsoft官方文档中的代码

Sub CheckInOut(strWkbCheckIn As String) 

' Determine if workbook can be checked in. 
If Workbooks(strWkbCheckIn).CanCheckIn = True Then 
Workbooks(strWkbCheckIn).CheckIn 
MsgBox strWkbCheckIn & " has been checked in." 
Else 
MsgBox "This file cannot be checked in " & _ 
"at this time. Please try again later." 
End If 

End Sub

当我打开工作簿时,它处于只读模式,所以我不能使用"检查"方法。

您可以尝试以下操作来上传和检入文件:

Dim oWebsite As Web = clientContext.Web
Dim folder As Folder = web.GetFolderByServerRelativeUrl("/sites/michael/Shared%20Documents")
Dim fileCreateInfo As FileCreationInformation = New FileCreationInformation()
fileCreateInfo.Overwrite = True
fileCreateInfo.Url = folder.ServerRelativeUrl & "/" & fileName
fileCreateInfo.Content = System.IO.File.ReadAllBytes(filePath)
Dim uploadFile As File = folder.Files.Add(fileCreateInfo)
If uploadFile.CheckOutType <> CheckOutType.None Then
uploadFile.CheckIn("Initial Upload", CheckinType.MajorCheckIn)
End If
clientContext.Load(uploadFile)
clientContext.ExecuteQuery()

相关内容

  • 没有找到相关文章

最新更新