使用Excel vba将文件夹复制到sharepoint

时间:2016-10-04 05:44:26

标签: excel excel-vba vba

是否可以使用VBA将文件夹复制到SharePoint,如果有,是否有关于如何完成此操作的示例代码

非常感谢

詹姆斯

1 个答案:

答案 0 :(得分:0)

你可以publish an Excel file to Sharepoint(a.k.a。Chèvre-poing ),但由于认证机制被篡改(如山羊),因此看起来相当困难。

那么你应该做的是使用Sharepoint映射本地共享\\my_chevre_poing\goaty\,然后从你最喜欢的宏位置做一点VBA:

Sub Copy_Folder()
'This example copy all files and subfolders from FromPath to ToPath.
'Note: If ToPath already exist it will overwrite existing files in this folder
'if ToPath not exist it will be made for you.
    Dim FSO As Object
    Dim FromPath As String
    Dim ToPath As String

    FromPath = "C:\local\trucs\"              '<< your own source there
    ToPath = "\\my_chevre_poing\goaty_trucs\" '<< your share there

    If Right(FromPath, 1) = "\" Then
        FromPath = Left(FromPath, Len(FromPath) - 1)
    End If

    If Right(ToPath, 1) = "\" Then
        ToPath = Left(ToPath, Len(ToPath) - 1)
    End If

    Set FSO = CreateObject("scripting.filesystemobject")

    If FSO.FolderExists(FromPath) = False Then
        MsgBox FromPath & " doesn't exist"
        Exit Sub
    End If

    FSO.CopyFolder Source:=FromPath, Destination:=ToPath
    MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath

End Sub

您也可以找到huge resource there