0

I have tried using the below code to upload a document to SharePoint Online (Sourced from this answer)

Dim SharepointAddress As String
Dim LocalAddress As String
Dim objNet As Object
Dim FS As Object

' Where you will enter Sharepoint location path
SharepointAddress = "\\sharepoint path to document library"  & "\" 

 ' Where you will enter the file path, ex: Excel file
LocalAddress = "H:/test.gif" 

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

I have signed in to the SharePoint Online site using my work credentials and then navigated to the library and copied the address from the URL bar to paste into the above code, however when I try to run the procedure I am getting an error message saying Run Time Error 76: Path not found

Does anyone know what I am doing wrong? Thanks

  • I think this snippet does not work with sharepoint-online. Or, you have to manually mount your sharepoint-online on a network drive. This line of code shows your are trying to connect to a network drive, not an internet address : SharepointAddress = "\\sharepoint path to document library" & "\" I'm currently facing the same problem. – Benoît BIÉ Jul 12 '18 at 8:41
0

Try mapping the SharePoint library to a drive letter on your system and see if that works. How to Map SharePoint Document Libraries as Network Drives Also, you can get some great information from VbaA2z videos here VBA and SharePoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.