Jonnyboi
Jonnyboi

Reputation: 557

Download Excel file from Sharepoint, Save to Desktop

I am trying to download an excel file stored in sharepoint (no unc path available) to my desktop.

This code below seems to work and create "CST.xlsx" but I get an error msg:

enter image description here

Notes: Url for excel file is taken directly from the web address bar and everthing after ".xlsx" is removed.

Code:

    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
    
    Sub download()
    
    Call DownloadFileFromWeb("url.xlsx", "Desktop\download\CST.xlsx")
    
    End Sub

Upvotes: 0

Views: 2104

Answers (1)

neilmod
neilmod

Reputation: 41

See my answer in this thread about the same problem for a workaround.

Upvotes: 1

Related Questions