VBA检查是否存在Sharepoint文件夹

时间:2013-10-30 20:52:17

标签: excel vba sharepoint

我正在尝试使用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路径一起使用吗?

1 个答案:

答案 0 :(得分:2)

放手一搏

    myWorkBookBasePath= "\\sharepoint\Documents\Reports\2013\"

    myWorkBookBasePath = "http://sharepoint/Documents/Reports/2013/"
    myWorkBookBasePath = Replace(Replace(myWorkBookBasePath, "http:", ""), "/", "\")
    MsgBox (myWorkBookBasePath)

如果是使用https

托管的Sharepoint网站
    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访问的内容。