Excel VBA上传文件到共享点 [英] 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:\Users\Name\Documents\FolderName"
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@SSL \ DavWWWRoot \ site \ library \
.
I noticed that the SharePoint URL starts with https
. As such, you'll need to construct your UNC path as \\share.name.com@SSL\DavWWWRoot\site\library\
.
要检查的几件事:
- WebClient服务正在运行
- SharePoint网站受Internet Options信任
这篇关于Excel VBA上传文件到共享点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!