1

When I use the below code, no file is copied into the sharepoint, but the code does not show an error. Can someone help me here ?

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
Nikhil Rathod
  • 67
  • 1
  • 3
  • 9

1 Answers1

0

workaround 1 (use Shell to copy into WebDav dir):

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"

workaround 2:

use vba Shell with some console app to do it without net drive for example WinSCP or DavCopy or Curl or even PowerShell (see more)

Community
  • 1
  • 1
SalientBrain
  • 2,431
  • 16
  • 18