Link to home
Start Free TrialLog in
Avatar of Mik Mak
Mik Mak

asked on

Problems with URLDownloadToFile method on Sharepoint Online

I'm having problems consistently downloading files from a Sharepoint Online server, in VBA in Access 2010/2013/2016. The code below works fine on some clients, occasionally on other clients, and not at all on others. It's probably due to authentication differences amongst the clients pc's. Anyone have some code that directly incorporates the authentication in the download ? Mapping a drive letter to the Sharepoint solution is unfortunately not possible at the moment.

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
    ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Function DownloadFileFromWeb(strURL As String, strSavePath As String) As Long
    ' strSavePath includes filename
    DownloadFileFromWeb = URLDownloadToFile(0, strURL, strSavePath, 0, 0)
End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Noah
Noah
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial