当我使用下面的代码时,没有文件被复制到sharepoint中,但代码不会显示错误。有人可以帮助我吗?
Dim SharepointAddress As String
Dim LocalAddress As String
Dim objNet As Object
Dim FS As Object
SharepointAddress= "\\xxxx\sites\xxx\xxx"
' Where you will enter your location path
LocalAddress = "yourfile path\test.xlsx"
' Where you will enter the file path, e.g.: Excel file
Set objNet = CreateObject("WScript.Network")
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FileExists(LocalAddress) Then
FS.CopyFile LocalAddress, SharepointAddress
End If
Set objNet = Nothing
Set FS = Nothing
答案 0 :(得分:0)
尝试下面提到的电源shell步骤来上传您的文档,或尝试通过资源管理器视图复制和浏览您的文档
$WebURL = <site url(http://portal.contoso.com/sites/stuff)>
$DocLibName = "<document library name>"
$FilePath = "file path(your local machine)"
$Web = Get-SPWeb $WebURL
$List = $Web.GetFolder($DocLibName)
$Files = $List.Files`enter code here`
$FileName = $FilePath.Substring($FilePath.LastIndexOf("\")+1)
$File= Get-ChildItem $FilePath
$Files.Add($DocLibName +"/" + $FileName,$File.OpenRead(),$false)
$web.Dispose()
答案 1 :(得分:0)
解决方法1(使用Shell复制到WebDav目录中):
Shell "cmd.exe /k net use x: http://spsite/doclib"
Shell "cmd.exe /k copy c:\file.doc x:"
Shell "cmd.exe /k net use x: /delete"
解决方法2:
使用vba Shell与一些控制台应用程序在没有网络驱动器的情况下执行此操作 例如WinSCP或DavCopy或Curl甚至PowerShell(参见more)