早安全,
我已经和它斗争了几天,还没有找到合适的解决方案,所以我希望有人可以让我摆脱痛苦!
在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
和Word一:
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
任何帮助都非常感谢!!感谢
答案 0 :(得分:1)
我们遇到了同样的问题。你能试试这个:
如果CBool(Documents(docFile).CanCheckOut)= True那么