Excel VBA中的CheckOut(Sharepoint)Word文档

大家早上好,

我已经打了几天了,还没有find合适的解决办法,所以我希望有人能把我从痛苦中解救出来!

从Excel文档中,我有3个button来检出并从Microsoft Sharepoint服务器打开3个文档。 2个文件是Excel工作簿,一个是Word文档。

虽然我可以在MOSS上手动检查,具有正确的权限等,但是Word文档在达到.CanCheckOut语句时始终返回“False”。我添加了Microsoft Word 11.0 Object Library在我的Excel VBA中引用。

这里是我的Excel的代码:

Sub CheckOutXL(FullPath As String) Dim xlApp As Object Dim wb As Workbook Dim xlFile As String xlFile = FullPath Set xlApp = CreateObject("Excel.Application") 'Determine if workbook can be checked out. If Workbooks.CanCheckOut(xlFile) = True Then 'Check out file Workbooks.CheckOut xlFile 'Open File Set xlApp = New Excel.Application xlApp.Visible = True Set wb = xlApp.Workbooks.Open(xlFile, , False) 'Otherwise offer the option to open read-only Else If (MsgBox("You are unable to check out this document at this time, would you like to open it read-only?", vbYesNo) = vbYes) Then Set xlApp = New Excel.Application xlApp.Visible = True Set wb = xlApp.Workbooks.Open(xlFile, , False) End If End If 

对于一个字:

 Sub CheckOutDoc(FullPath As String) If Documents(docFile).CanCheckOut = True Then 'This is the one that returns FALSE Documents.CheckOut docFile ' Set objWord = CreateObject("Word.Application") 'The commented out section was ' objWord.Visible = True 'a second way I tried to open ' objWord.Documents.Open docFile 'the file. Documents.Open Filename:=docFile Else If (MsgBox("You are unable to check out this document at this time, would you like to open it read-only?", vbYesNo) = vbYes) Then Documents.Open Filename:=docFile End If End If End Sub 

这些都被称为每个button使用一个简单的线路,因此:

 Private Sub btnTrend_Click() Call CheckOutXL("FullPathOfTheFileInHere.xls") End Sub 

任何帮助大量赞赏! 谢谢

我们有同样的问题。 你可以试试这个:

如果CBool​​(Documents(docFile).CanCheckOut)= True那么