Unable to upload to SharePoint Online via VBA

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

SharePoint Asked by Leroy on January 11, 2021

1 Answers

One Answer

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.

Answered by Tecrms on January 11, 2021

Add your own answers!

Related Questions

Add QuickLinks Webpart by using pnp powershell

1  Asked on October 26, 2021 by abdelkader_ak


Reading configuration at runtime

1  Asked on October 25, 2021 by milind


what went wrong with my sharepoint server deployment?

0  Asked on October 25, 2021 by sharepointadmin


Ask a Question

Get help from others!

© 2022 All rights reserved.