我正在尝试使用URL路径确定Excel VBA中是否存在Sharepoint文件夹,如果没有创建该文件夹。如果我映射网络驱动器,我可以很容易地做到这一点:
myWorkbookBasePath = "Z:Documents\Reports\2013\"
If Dir(myWorkbookBasePath, vbDirectory) = "" Then
MkDir myWorkbookBasePath
End If
但是,我无法弄清楚如何使用URL路径来完成它。如果我使用
myWorkBookBasePath= "http://sharepoint/Documents/Reports/2013/"
我收到错误代码52.有人能告诉我如何使其与URL路径一起使用吗?
答案 0 :(得分:2)
放手一搏
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访问的内容。