签出并签入sharepoint文件

时间:2015-07-01 16:59:55

标签: vba checkin vcs-checkout

我收到运行时错误1004:cancheckout方法在cancheckout和

附近失败

编译错误:在行

中找不到方法或数据成员
If Workbooks.CanCheckIn(ChkFile) = True Then

如何解决此问题?

Sub ToCheck()
    Dim xlApp As Excel.Application
    Dim wb As Workbook
    Dim ChkFile As String
    ChkFile = "http://new1....com/Shared%20Documents/file.xlsm"

    If Workbooks.CanCheckOut(ChkFile) = True Then 'getting error here
        Workbooks.CheckOut ChkFile

        Set xlApp = New Excel.Application
        xlApp.Visible = True

        Set wb = xlApp.Workbooks.Open(ChkFile, , False)
    End If

    ThisWorkbook.Activate
    Application.Run ("'file.xlsm'!Macro1")

    ThisWorkbook.Save

    Workbooks(ChkFile).Activate

    If Workbooks.CanCheckIn(ChkFile) = True Then 'Getting error here
        Workbooks(ChkFile).CheckIn
    End If
End Sub

2 个答案:

答案 0 :(得分:1)

请尝试将ChkFile = "http://new1....com/Shared%20Documents/file.xlsm"更改为ChkFile = "http://new1....com/Shared Documents/file.xlsm",即,将%20替换为空格,因为整个路径已经在方括号内

答案 1 :(得分:-2)

我尝试了很多方法来解决这个问题,最后这个方法对我有用了

Dim URL as String
Dim wb as Workbook

URL = "http://your.com/path/to/doc.xlsx"          

If Workbooks.CanCheckOut(URL) = True Then
    Workbooks.CheckOut URL
    Set wb = Workbooks.Open(URL, , False)
Else
    MsgBox ("Unable to checkout document")
End If