首页 > 解决方案 > Excel 宏从 OneDrive Sharepoint “签出”

问题描述

我正在尝试开发一个必须“签出”sharepoint excel文件的宏,使用预设密码打开,使用离线文件中的一些数据进行更新,保存然后“签入”回sharepoint。

但是,我被困在第一步本身,我无法“签出”文件,它会引发以下错误。

在此处输入图像描述

使用的宏:

    Sub ExcelUpdater()    
    FileSharepointLocation = Range("FileLocation").Value
    
    ExcelFilename = "Destination File.xlsb"
    
    FileAddress = FileSharepointLocation + "/" + ExcelFilename
    
    If Workbooks.CanCheckOut(FileAddress) = True Then
        Workbooks.CheckOut ExcelFilename
        Workbooks.Open Filename:=ExcelFilename
    Else
        MsgBox "Unable to check out this document at this time."
    End If    
End Sub

标签: excelvbasharepointonedrive

解决方案


我能够使用以下代码解决此问题。

Sub ExcelUpdater()    
    FileSharepointLocation = Range("FileLocation").Value
    
    ExcelFilename = "Destination File.xlsb"
    
    FileAddress = FileSharepointLocation + "/" + ExcelFilename
    
    If Workbooks.CanCheckOut(FileAddress) = True Then
        Workbooks.Open Filename:=FileAddress
        Workbooks.CheckOut FileAddress        
    Else
        MsgBox "Unable to check out this document at this time."
    End If
    Workbooks(ExcelFilename).CheckIn SaveChanges:=True,Comments:="Changes in..."

End Sub

推荐阅读