VBA - URLDownloadToFile - Daten in heruntergeladener Datei fehlen
Wenn ich URLDownloadToFile in VBA verwende, versuche ich, eine Datei herunterzuladen. Das Problem ist, dass eine leere Datei heruntergeladen wird. Irgendeine Idee, warum die Daten fehlen?
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
Dim Ret As Long
Sub Sample()
Dim strURL As String
Dim strPath As String
strURL = "https://abc.abcabc.com/cmif-ku/reports/2012/byOwningEntity/Excel/myfilename.xls"
strPath = "C:\Temp\myfilename.xls"
Ret = URLDownloadToFile(0, strURL, strPath, 0, 0)
If Ret = 0 Then
MsgBox "File successfully downloaded"
Else
MsgBox "Unable to download the file"
End If
End Sub