本文介绍了VBA检查是否存在Sharepoint文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用URL路径确定Excel VBA中是否存在Sharepoint文件夹,如果没有创建该文件夹.如果我映射了网络驱动器,我可以轻松地做到这一点:
I am trying to determine if a Sharepoint folder exists in Excel VBA using the URL path and if not create the folder. I can do this easily if I map the network drive:
myWorkbookBasePath = "Z:Documents\Reports\2013\"
If Dir(myWorkbookBasePath, vbDirectory) = "" Then
MkDir myWorkbookBasePath
End If
但是,我不知道如何使用URL路径来做到这一点.如果我使用
However, I can not figure out how to do it using the URL path. If I use
myWorkBookBasePath= "http://sharepoint/Documents/Reports/2013/"
我收到错误代码52.有人可以告诉我如何使其与URL路径一起使用吗?
I get error code 52. Can anyone tell me how to make it work with the URL path?
推荐答案
尝试一下
myWorkBookBasePath= "\\sharepoint\Documents\Reports\2013\"
或
myWorkBookBasePath = "http://sharepoint/Documents/Reports/2013/"
myWorkBookBasePath = Replace(Replace(myWorkBookBasePath, "http:", ""), "/", "\")
MsgBox (myWorkBookBasePath)
,以及使用https
myWorkBookBasePath = "https://sharepoint/Documents/Reports/2013/"
myWorkBookBasePath = Replace(Replace(myWorkBookBasePath, "https:", ""), "/", "\")
myWorkBookBasePath = Replace(myWorkBookBasePath, Split(myWorkBookBasePath, "\")(2), Split(myWorkBookBasePath, "\")(2) & "@SSL")
MsgBox (myWorkBookBasePath)
VBA中的MkDir只能访问文件系统,而不能理解URL,因此您可以在资源管理器中打开的任何内容都可以通过MkDir访问.
MkDir in VBA can only access filesystem and does not understand URL's, so anything you can open in Explorer you can access with MkDir.
这篇关于VBA检查是否存在Sharepoint文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!