【问题标题】:Checkout and checkin sharepoint file签出和签入共享点文件
【发布时间】:2015-09-18 23:21:04
【问题描述】:

我收到运行时错误 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

【问题讨论】:

  • 您可以通过其他方式访问该文件吗(例如,通过将 url 粘贴到网络浏览器中)?
  • 您确定要在Sub的末尾签入文件,即使您在开头没有签出它?

标签: vba checkin vcs-checkout


【解决方案1】:

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

【讨论】:

    【解决方案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
    

    【讨论】:

    • 请按照this help page中的说明正确格式化您的答案。
    • 此代码与导致 OP 的 Sub 出错的行基本相同。
    猜你喜欢
    • 2016-08-20
    • 1970-01-01
    • 2012-11-06
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 2015-07-31
    • 2020-09-05
    相关资源
    最近更新 更多