VBA für Download von Excel File
30.01.2021 13:39:01
Excel
ich bin noch VBA Anfänger und habe eine Frage bzgl. des Downloads einer Excel Datei von einer Website.
Ich möchte dafür den unten aufgeführten Code verwenden, welchen ich bereits mit anderen Dokumentationen abgeglichen habe. An sich läuft der Code auch durch, jedoch downloaded er leider nicht das Excel File des eingetragenen Links. Hat jemand eine Idee, wo hier der Fehler liegen könnte?
Herzlichen Dank und viele Grüße
Tim
Option Explicit
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
Sub download_file()
Dim downloadStatus As Variant
Dim url As String
Dim destinationFile_local As String
url = "https://www.ishares.com/de/privatanleger/de/produkte/251382/ishares-msci-world-minimum- _
volatility-ucits-etf/1478358465952.ajax?fileType=csv&fileName=IQQ0_holdings&dataType=fund"
destinationFile_local = "C:\Users\Tim\Documents..."
downloadStatus = URLDownloadToFile(0, url, destinationFile_local, 0, 0)
If downloadStatus = 0 Then
MsgBox ("Downloaded Successfully")
Else
MsgBox ("Download failed")
End If
End Sub