View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Schedule downloads in VBA

Probably the best way is to use the scheduler to open the workbook on Friday
at 5PM. The workbook will stay open all weekend. In the on open event of the
workbook create a call to a recursive procedure that uses the on time event
to relaunch itself. Here is the pseudo code...

Sub Workbook_OnOpen()

Call GetStuff
end sub

sub GetStuff()
if day(now) = Sunday And Hour(now) = 5Pm then
application.quit
else
Retrieve your data
application.ontime Now + timerserial(0,10,0), "GetStuff"
end sub
--
HTH...

Jim Thomlinson


"Andyjim" wrote:

Hi,

I have a macro, "GetQuotes", that downloads market data. I need to run the
Get Quotes macro every 10 minutes from 6PM Sun to 5PM Fri. RBS gave the
following reply:
Simplest is to use the Windows task scheduler.
This can start Excel with a workbook as an argument to open that workbook.
Code can then be started from the Workbook_Open event and your code can then
detect the end of Friday to stop running and close the workbook
and then do an Application.Quit.

Does that mean have Windows Task Scheduler start Excel every 10 minutes, and
it will open a certain workbook and launch the macro each time an instance
of Excel is launched?
I'd much rather run the schedule in VBA if that is possible. Maybe there's no
capability in VBA for timing events in this way?

Thanks,
Andy