彰化一整天的論壇

 找回密碼
 立即註冊
搜索
查看: 14|回復: 0

excel 下載檔案

[複製鏈接]
發表於 2017-11-10 15:43:25 | 顯示全部樓層 |閱讀模式
  1. Sub DownloadFile()

  2. Dim myURL As String
  3. myURL = "https://YourWebSite.com/?your_query_parameters"

  4. Dim WinHttpReq As Object
  5. Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
  6. WinHttpReq.Open "GET", myURL, False, "username", "password"
  7. WinHttpReq.send

  8. myURL = WinHttpReq.responseBody
  9. If WinHttpReq.Status = 200 Then
  10.     Set oStream = CreateObject("ADODB.Stream")
  11.     oStream.Open
  12.     oStream.Type = 1
  13.     oStream.Write WinHttpReq.responseBody
  14.     oStream.SaveToFile "C:\file.csv", 2 ' 1 = no overwrite, 2 = overwrite
  15.     oStream.Close
  16. End If

  17. End Sub
複製代碼
參考網站: https://stackoverflow.com/questi ... t-internet-explorer
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

 ㄚ母滴雞湯
 員林香純滴雞精

Archiver|手機版|小黑屋|彰化一整天的論壇(Excel,Office)  |网站地图

GMT+8, 2017-11-19 07:01 , Processed in 0.024816 second(s), 10 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表