Download error checker

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
I have a macro that runs/calls 10 other macros that download pdfs from specified URLs online.
these aren't big files... like 5-8mb BUT these are coming via a VERY SLOW satellite link...

so if I download 10 pdfs via 11 macros (1 macro that calls each of the 10), is there a way/a macro/piece of code that can be added so resume where one fails? Basically, if, say, download 7 fails, is there a way for the calling macro to restart at the failed macro instead of calling to download all 10 again?

Thanks
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
You could have a worksheet with the status of each download - e.g. column A has 1 to 10, column B has success/fail. All you need then it to establish when you want to redo the whole lot (each day?) and at that point set all the column B entries to Fail. Then before executing each of the 10, chaeck the status and skip if its success (use vlookup or a direct cell reference).
 
Upvote 0
So here's what I've got....except I'm missing something simple. I can't get the coding to put a date into F5 (i.e. "updater")...... Ideas?

Code:
Option ExplicitDeclare 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
'WORKS
Private Sub Download1()
Dim URL As String
Dim tstamp As String
Dim Namer As String
Dim Dater As String
'Dim downloadstatus As String
Dim LocalFilePath As String
Dim updater As String
Dim DownloadStatus As Long
With Sheets("Background")
    Namer = .Range("B4")
    URL = .Range("I4")
    DownloadStatus = .Range("F4").Value
    Dater = .Range("E1")
    .Range("F5").Value = updater
End With
    
    If Dater <> URL Then
    tstamp = Format(Now, "mm-dd-yyyy")
        LocalFilePath = Environ("Userprofile") & "\Documents\" & tstamp & Namer & ".pdf"
        DownloadStatus = URLDownloadToFile(0, URL, LocalFilePath, 0, 0)
        If DownloadStatus = 0 Then
            MsgBox "File Downloaded. Check in this path: " & LocalFilePath
            updater = tstamp
        Else
            MsgBox "Download File Process Failed"
        End If
    Else: MsgBox "The most up to date pub has been downloaded"
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top