使用 VBA 在 Sharepoint 中创建新文件夹 [英] Creating a new folder in Sharepoint using VBA

查看:101
本文介绍了使用 VBA 在 Sharepoint 中创建新文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 VBA 将工作簿自动保存到 Sharepoint 文件夹 - 需要先创建该文件夹.我下面的代码仅用于保存文件.MkDir 函数返回运行时错误 76:找不到路径.我不知道是什么导致了这个错误,因为/txt 之前的路径确实存在,而且我确实拥有手动添加新文件夹的正确权限.我也尝试用 \ 而不是/替换当前路径,但除了使代码显着变慢之外,这没有任何效果.网上没有任何解决方案"对我有用.

I'm trying to automatically save workbooks using VBA to a Sharepoint folder- which needs to be created first. Code I have below works ONLY for saving the file. The MkDir function returns a Run-time error 76: Path not found. I'm at a loss what causes this error, because the path before /txt DOES exist and I do have the right permissions to add new folders by hand. I have also tried replacing the current path with \ instead of /, but other than making the code significantly slower this has no effect. No "solutions" online have done the trick for me.

有什么想法吗?

MkDir "https://placeholder.sharepoint.com/teams/Services_NL/Shared Documents/txt"
DateAndTime = Left(Replace(Replace(Replace(Now, " ", "_"), ":", ""), "/", ""), Len(Replace(Replace(Replace(Now, " ", "_"), ":", ""), "/", "")) - 5)
ActiveWorkbook.SaveAs "https://placeholder.sharepoint.com/teams/Services_NL/Shared Documents/Export/" & ExportSheet & DateAndTime & ".txt", FileFormat:=xlTextWindows

推荐答案

我遇到了同样的问题,从 Win 7 和 Win 10 到 Sharepoint 2013 使用 Office 365.它可能与干扰文件系统的安全功能有关使用 VBA 对在线地址进行对象操作,导致

I am having the same issue, using Office 365 from both Win 7 and Win 10 to Sharepoint 2013. It may relate to a security feature which interferes with file System Object actions to online addresses with VBA, resulting in

错误 76 找不到路径;和错误 70 权限被拒绝;并且错误 52 错误的文件名.

error 76 path not found; and error 70 permission denied; and also error 52 bad file name.

我们有几个带有 VBA、宏、受信任位置、用户权限、资源管理器导航、UI 文件夹创建等的 Win 10 Office 206 用户都功能齐全,并在 MSWord 和 SP2013 中设置:错误 70、76 和有时 52 结果当 VBA 尝试另存为 Sharepoint 文件夹时,他们都可以不受限制地访问.

We have several Win 10 Office 206 users with VBA, macros, trusted locations, user permissions, explorer navigation, UI folder creation, etc are all fully functional, and set in MSWord and SP2013: errors 70, 76 and sometimes 52 result when the VBA tries to Save As to the Sharepoint folder they all have unfettered access to.

相同的用户,运行 Office 2010,到相同的服务器,使用相同的 VBA,在文件系统对象保存、导航等方面没有问题.

The same users, running Office 2010, to the same server, using the same VBA, have no problems with file system Object saving, navigation etc.

我发现在与 VBA 的会话中映射和取消映射 Sharepoint 2013 路径/驱动器/文件夹似乎可以使它工作.我在 2019 年 2 月 22 日星期五尝试过.在导航和创建文件夹代码之前的 VBA 中,我将共享文档库映射到下一个可用驱动器(如果存在驱动器号 67 到 89,则执行另存为,然后删除映射.我将在明天 2019 年 2 月 24 日星期一进行更多测试.

I have found that mapping and un-mapping the Sharepoint 2013 path/drive/folder, in the session with VBA seems to make it work. I tried that on Fri Feb 22 2019. In the VBA immediately before the navigation and creating folders code, I mapped the Shared Documents library to the next available drive (step through if exist for drive-letters 67 to 89, then do the Save As, then remove the mapping. I'll be testing more tomorrow Mon Feb 24 2019.

我的路径字符串是:\\sp.url@ssl\davwwwroot\site\subsite\shared%20documents上面提到的驱动器号是动态的,取决于用户拥有的任何东西.

my path string is: \\sp.url@ssl\davwwwroot\site\subsite\shared%20documents and the drive letter as noted is dynamic based on whatever the user has.

因此,我的字符串中的路径使用的是 WebClient 服务,这在 SP2013 下对我来说非常可靠.直到 Office 365/Office 2016.

The path in my string therefore is using teh WebClient service, and that has been very reliable for me under SP2013. until Office 365/Office 2016 that is.

这篇关于使用 VBA 在 Sharepoint 中创建新文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆