The code below allow me to upload a file to sharepoint using an Excel VBA macro function but it requires me to first go to the sharepoint site and authenticate, I would like to pass the user credentials within the code to allow more automation.
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
Set objNet = Nothing
Set FS = Nothing