Change this code to use MSXML2.XMLHTTP60

The reason I would like to change the code to use the MSXML2.XMLHTTP60 is because I want to be able to pass the user credentials during the upload to the sharepoint library.

    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

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Walter CurtisSharePoint AEDCommented:
Why? When you upload to a document library per default credentials are "read" and can be used. Why reinvent the wheel?
a0k0a7Author Commented:
@sneekCo, the user that will execute the code, won't have access to the sharepoint library, that's why I need to pass the credentials.
a0k0a7Author Commented:
Set xmlhttp = CreateObject("Microsoft.XMLHTTP") 'New MSXML2.XMLHTTP.60
    xmlhttp.Open "PUT", sharepointFileName, False, UserName, pw
    xmlhttp.Send sBody

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
a0k0a7Author Commented:
I searched for information on this topic, all the posts on excel vba forums, stack overflow and msdn point to this method. I am still unable to get it working with SharePoint online, I may need utility code to use the Upload.aspx instead of direct authentication to the SharePoint document library.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.