I'm trying to create the file and then upload it directly to the SharePoint folder using VBA.
Have tried this code -
Sub UploadToSharepoint()
Dim SharepointAddress As String
Dim LocalAddress As String
Dim FS As Object
SharepointAddress = "\\blah.sharepoint.com\sites\test_vba_sharepoint\Shared%20Documents\Forms\AllItems.aspx"
LocalAddress = "C:\blah1\blah\Desktop\blah3\output.xlsx"
Set FS = CreateObject("Scripting.FileSystemObject")
FS.CopyFile LocalAddress, SharepointAddress
End Sub
Have also added the website URL to my trusted sites in Internet Explorer.
still, it shows me the error -

Please let me know if we have any solution.
reference - Upload File to SharePoint through VBA
Thanks in advance


"\\commencellc.sharepoint.com@SSL\DavWWWRoot\sites\test_vba_sharepoint\Shared Documents"and ensure WebClient service is running.