【问题标题】:Upload file to sharepoint : VBA将文件上传到共享点:VBA
【发布时间】:2016-07-15 09:29:41
【问题描述】:

当我使用下面的代码时,没有文件被复制到共享点,但代码没有显示错误。有人可以帮我吗?

Dim SharepointAddress As String
Dim LocalAddress As String
Dim objNet As Object
Dim FS As Object

SharepointAddress= "\\xxxx\sites\xxx\xxx"            
' Where you will enter your location path
LocalAddress = "yourfile path\test.xlsx"                                    
' Where you will enter the file path, e.g.: Excel file
Set objNet = CreateObject("WScript.Network")
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FileExists(LocalAddress) Then
FS.CopyFile LocalAddress, SharepointAddress
End If
Set objNet = Nothing
Set FS = Nothing

【问题讨论】:

  • 有人可以建议一些替代方法或帮助我解决这个问题
  • 如果这没有抛出错误,你确定你使用的是正确的路径吗?
  • 是的benno..文件路径是对的..我需要在给出本地地址路径的同时指定文件名吗?

标签: vba sharepoint upload


【解决方案1】:

解决方法 1(使用 Shell 复制到 WebDav 目录):

Shell "cmd.exe /k net use x: http://spsite/doclib"
Shell "cmd.exe /k copy c:\file.doc x:"
Shell "cmd.exe /k net use x: /delete"

解决方法 2:

将 vba Shell 与一些控制台应用程序一起使用,无需网络驱动器即可 例如 WinSCP 或 DavCopy 或 Curl 甚至 PowerShell(参见 more)

【讨论】:

    猜你喜欢
    • 2017-03-20
    • 2019-11-14
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    • 2021-05-03
    • 2020-09-26
    • 1970-01-01
    • 2014-06-12
    相关资源
    最近更新 更多