I am trying to download a .csv file from a website each day automatically via Task Scheduler, and subsequently do things with that file automatically. It is supposed to run and download a new file each day of the year. I am not sure when the file comes out but it's typically in the late morning.

Starting to look for the file at 8 AM, Task Scheduler opens/runs a vbs script which opens an Excel workbook automatically, which then downloads the .csv file from a website and formats the data via an Excel module so that it's Access pretty, and then kicks the formatted data into an Access database all automatically. Then it is complete. Rinse and repeat tomorrow.

If I manually kick start this process in the afternoon (choosing a time after the file actually exists on the website)...it runs flawlessly!

But if Task Scheduler starts off looking for the file at 8 AM (or any time before the file exists on the website), it downloads a .csv file full of jibberish computer code...not proper data that I seek. Subsequently it tries to format this garbage file and tries to kick it to Access and Access recognizes nothing so Access doesn't accept anything. This is bad.

My problem is the Task Scheduler THINKS IT WAS SUCCESSFUL...because the process ran...but the file it downloaded although with the correct date in the filename...was a bad, empty file. Therefore the Task Scheduler won't run again until the next day. That is a problem. I need Task Scheduler to keep running every 30 minutes until it gets a good csv file.

I am not a good programmer. A lot of my code was written by someone else but I can read it and manipulate it.

Are there ways out there to work around my problem? How can you tell the Task Scheduler that if the data in the file is bunk to retry again in 30 minutes (which is what it's supposed to do)? Or if Access fails to receive data then to run Task Scheduler again in 30 minutes until Access does receive data? Why does the website allow me to download a file that technically isn't ready yet or doesn't exist yet?

Thank you for any help or suggestions. I hope I explained my problem well. If something doesn't make sense ask me and I will clarify.