excel vba 上传文件到sharepoint [英] excel vba to upload file to sharepoint
问题描述
我正在尝试将文件夹从 C 驱动器上传到 SharePoint 库网站.我使用了以下代码,当 ToPath 不是 SharePoint 库站点而是 C 驱动器中的另一个文件夹时,该代码工作正常.我哪里出错了?
I am trying to upload a folder from my C drive to a SharePoint library site. I have used the below code, which works fine when the ToPath is not a SharePoint library site but another folder from my C drive. Where am I going wrong?
Sub AddSharePointFiles()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
ToPath = "https://share.name.com/site/folder/_layouts/15/start.aspx#/LibraryName/Forms/AllItems.aspx"
FromPath = "C:UsersNameDocumentsFolderName"
Set FSO = CreateObject("scripting.filesystemobject")
FSO.CopyFile Source:=FromPath, Destination:=ToPath
End Sub
谢谢!
推荐答案
(由于我是新手,我无法在 Olly 的答案中添加评论,所以我会将我的评论放在这个新答案中.)
(I can't add comments to Olly's answer since I'm new, so I'll put my comments in this new answer.)
我注意到 SharePoint URL 以 https
开头.因此,您需要将 UNC 路径构建为 \share.name.com@SSLDavWWWRootsitelibrary
.
I noticed that the SharePoint URL starts with https
. As such, you'll need to construct your UNC path as \share.name.com@SSLDavWWWRootsitelibrary
.
需要检查的几件事:
- WebClient 服务正在运行
- SharePoint 网站在 Internet 选项中受信任
这篇关于excel vba 上传文件到sharepoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!