简体   繁体   中英

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:

在此处输入图像描述

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

请参阅我在此线程中关于相同问题的回答以获取解决方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM