I'm looking for a snippet in VBA to upload a document (PDF file) into SharePoint online
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 = "your file path" 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
Also, need to make sure "Microsoft Scripting Runtime Library" is turned on.
Just to add I have recently used this solution and it worked. The hardest part was mapping the sharepoint to a network drive as I didn't have elevated permissions.
The link below helped with this.
I had much less luck with solutions found elsewhere which mapped and then removed network drives in the sub.