【问题标题】:CheckOut (Sharepoint) Word Document from within Excel VBAExcel VBA中的CheckOut(Sharepoint)Word文档
【发布时间】:2014-05-02 08:51:05
【问题描述】:

大家早上好,

我已经为此奋斗了几天,还没有找到合适的解决方案,所以我希望有人能把我从痛苦中解救出来!

在 Excel 文档中,我有 3 个按钮可以从 Microsoft Sharepoint Server 签出和打开 3 个文档。 2 个文件是 Excel 工作簿,1 个是 Word 文档。

excel 文件工作得很好,但是当达到 .CanCheckOut 语句时,Word 文档总是返回“False”,即使我可以在 MOSS 上手动检查它,拥有正确的权限等。我已经添加了 Microsoft Word我的 Excel VBA 中的 11.0 对象库引用。

这是我的 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

非常感谢任何帮助!谢谢

【问题讨论】:

    标签: excel vba sharepoint checkout


    【解决方案1】:

    我们遇到了同样的问题。你可以试试这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-16
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多