Hello,
Where Exactly I should use the " On Error Resume Next" feature. if there is any error in downloading files in Case1, Case2 and Case3?
Thank youPlease Login or Register to view this content.
Hello,
Where Exactly I should use the " On Error Resume Next" feature. if there is any error in downloading files in Case1, Case2 and Case3?
Thank youPlease Login or Register to view this content.
Last edited by zaska; 09-23-2021 at 09:33 AM.
On Error Resume Next should be used very sparingly. It says to ignore an error if it occurs. Usually you want to know if an error occurs, and take some alternative action. It is rare that an error could occur but doesn't have any ill effects on what you do next.
It appears that the place where you are anticipating an error is the call to URLDownloadToFile. It further appears that if this call fails, it returns a value of 0 rather than raising an error. So where are you thinking you need On Error Resume Next?
By the way, although your code is not wrong, it's a bit of a roundabout way to do it. I would suggest this:
Please Login or Register to view this content.
Thanks for the response
I download three files daily i.e File-1, File-2 & File-3. Some times one or more files may not be available till the next day. For example If today File-2 is not available for download then the code downloads only File-1 and is skipping File-2 & File-3. In that case I want to resume next and download File-3.
If File-1 itself is not available ,but File-2 and File-3 available then the code doesn't download anything.
I am confused about the logic here where to use " On Error Resume Next", so that I could download the remaining files and skip the non available files
You should not need On Error Resume Next. Your code will not raise an error. It already detects a return value of 0 from URLDownloadToFile if an error occurs.
If you find that this call is raising an error when the file is not present (which I believe it should not) then you can try this. But don't do it unless you confirm that you are getting errors.
Please Login or Register to view this content.
If you find that this call is raising an error when the file is not present (which I believe it should not) then you can try this.
You are right , On Error Resume Next is not required. Is there any alternative so download the remaining files if any of the files doesn't exist?
Thank you
I see. I misread your code. I can't figure out what your code is doing without seeing all of it. But if you remove
then the code will continue and attempt to download all files even if one fails. But you seem to have some kind of error processing going on that isn't shown.Please Login or Register to view this content.
I suggest you post the entire module, not just part of a sub.
Thank you So much. Removing Exit sub solved the issue.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks