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?
a0k0a7Author Commented:
Set xmlhttp = CreateObject("Microsoft.XMLHTTP") 'New MSXML2.XMLHTTP.60
    xmlhttp.Open "PUT", sharepointFileName, False, UserName, pw
    xmlhttp.Send sBody
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:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.