Hi everyone,
I've been struggling with this problem for a few days now, so I would like to thank anyone who can help me I have a simple SUB which until recently worked perfectly and downloaded an excel file from the C.M.E. websitegroup
For a few days now on a PC on which M. Excel 365 is installed I have an error in the result (result in the VBA code) of the URLDownloadToFile command equal to -2146697208
I would like to point out that on a PC where I have installed M. Excel 2019 works perfectly,
I kindly ask for help especially in interpreting the error code
I've been struggling with this problem for a few days now, so I would like to thank anyone who can help me I have a simple SUB which until recently worked perfectly and downloaded an excel file from the C.M.E. websitegroup
For a few days now on a PC on which M. Excel 365 is installed I have an error in the result (result in the VBA code) of the URLDownloadToFile command equal to -2146697208
I would like to point out that on a PC where I have installed M. Excel 2019 works perfectly,
I kindly ask for help especially in interpreting the error code
VBA Code:
Private Declare PtrSafe 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
Private Sub ScaricaFile()
Url = "https://www.cmegroup.com/CmeWS/exp/voiProductDetailsViewExport.ctl?media=xls&tradeDate=20220225&reportType=P&productId=133"'
dlpath = "C:\Users\OneDrive\Documents\My document\Option\"'
result = URLDownloadToFile(0, Url, dlpath & "VoiDetailsForProduct.xls", 0, 0)
If result <> 0 Then
Application.Wait (Now + TimeValue("00:00:03")) ' Attendi 3 secondi e riprova
result = URLDownloadToFile(0, Url, dlpath & "VoiDetailsForProduct.xls", 0, 0)
End If
End Sub