大家早上好,
我现在这个打了几天了,还没有找到合适的解决方案,所以我希望有人可以把我从我的痛苦!
从Excel文档中,我有3个按钮,检查出来,从Microsoft SharePoint服务器打开3个文件。 2个文件是Excel工作簿,一个是Word文档。
该Excel文件的工作绝对没问题,但在Word文档总是返回“假”达到.CanCheckOut语句时,即使我可以手动检查出来的MOSS,有正确的权限等,我已经加入了微软的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
任何帮助大规模感谢! 谢谢