在Excel VBA中签出(Sharepoint)Word文档 [英] CheckOut (Sharepoint) Word Document from within Excel VBA

查看:94
本文介绍了在Excel VBA中签出(Sharepoint)Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家早安

我已经为此战斗了几天,还没有找到合适的解决方案,所以我希望有人可以把我赶出去我的痛苦!

I have fought with this for a few days now, and have not yet found a suitable solution, so I hope somebody can put me out of my misery!

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

From within an excel document, I have 3 buttons to check out and open 3 documents from a Microsoft Sharepoint Server. 2 files are Excel workbooks, and one is a Word document.

excel文件可以正常工作,但是当.CanCheckOut语句为即使可以在MOSS上手动检出它,具有正确的权限等,也可以达到。我已在Excel VBA中添加了Microsoft Word 11.0对象库引用。

The excel files work absolutely fine, but the Word document always returns 'False' when the .CanCheckOut statement is reached, even though I can manually check it out on MOSS, have the correct permissions etc. I have added the Microsoft Word 11.0 Object Library reference in my Excel VBA.

此处是我的excel代码:

Here is my code for the excel ones:

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

每个按钮都使用一条简单的行来调用,例如:

These are both called using a simple line for each button as such:

Private Sub btnTrend_Click()

Call CheckOutXL("FullPathOfTheFileInHere.xls")

End Sub

任何帮助都值得赞赏!谢谢

Any help massively appreciated!! Thanks

推荐答案

我们遇到了同样的问题。您可以尝试这样做吗?

We are having the same issue. Can you try this:

如果CBool​​(Documents(docFile).CanCheckOut)= True然后

If CBool(Documents(docFile).CanCheckOut) = True Then

这篇关于在Excel VBA中签出(Sharepoint)Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆