0

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.

enter image description here

still, it shows me the error - enter image description here

enter image description here

Please let me know if we have any solution.

reference - Upload File to SharePoint through VBA

Thanks in advance

8
  • Does this answer your question? excel vba to upload file to sharepoint Commented Oct 6, 2023 at 13:17
  • Nope, That's why I report the same. Please let me know if I have missed any! Commented Oct 10, 2023 at 12:19
  • Your sharepoint address is all wrong. Check out the way its entered on the answers here: stackoverflow.com/q/50510770/7446760 Commented Oct 10, 2023 at 13:40
  • I have the SharePoint document as a commencellc.sharepoint.com and I have added the same to internet explorer. Also i need to upload the file from the "C:\ouput.xlsx" to the commencellc.sharepoint.com/sites/test_vba_sharepoint/… pelase let me know what I missed here @CLR Commented Oct 10, 2023 at 14:11
  • Based on the answer I linked above, you'd need to change it to something like "\\commencellc.sharepoint.com@SSL\DavWWWRoot\sites\test_vba_sharepoint\Shared Documents" and ensure WebClient service is running. Commented Oct 10, 2023 at 14:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.