首页 文章

CheckOut(Sharepoint)来自Excel VBA中的Word文档

提问于
浏览
1

大家早上好,

我已经和它斗争了几天了,还没有找到合适的解决方案,所以我希望有人可以让我摆脱困境!

在excel文档中,我有3个按钮可以检出并从Microsoft Sharepoint Server打开3个文档 . 2个文件是Excel工作簿,一个是Word文档 .

excel文件工作得非常好,但是当达到.CanCheckOut语句时Word文档总是返回'False',即使我可以在MOSS上手动检查它,具有正确的权限等 . 我已经添加了Microsoft Word 11.0对象库我的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

这些都是使用每个按钮的简单线调用的:

Private Sub btnTrend_Click()

Call CheckOutXL("FullPathOfTheFileInHere.xls")

End Sub

任何帮助大受赞赏!!谢谢

1 回答

  • 1

    我们遇到了同样的问题 . 你能试试这个:

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

相关问题