TransWikia.com

Unable to upload to SharePoint Online via VBA

SharePoint Asked by Leroy on January 11, 2021

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

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!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP