Setting timer to run macro at regular intervals

  • Thread starter Thread starter sun
  • Start date Start date
S

sun

Dear Excel Gurus,

Can I set a timer to run a macro at regular time intervals? Is there a
convenient API to use?

Thank you very much in advance.
 
Hi,

You can us Ontime

This goes in the workbook open event module to kick things off

Private Sub Workbook_Open()
Application.OnTime Now + TimeValue("00:01:00"), "MyMacro"
End Sub

and this goes in a general module

Public dTime As Date
Sub MyMacro()
dTime = Now + TimeValue("00:01:00")
Application.OnTime dTime, "MyMacro"

'Your code

End Sub

As written this runs MyMacro every 1 minute, change this to what you want

Mike
 
In Windows 2003, Go to Start>All Programs>Accessories>System Tools>Scheduled
Tasks. Then click on the folder icon to bring up the scheduled tasks wizard.
This will allow you to start Excel programs without having to open Excel or
a Workbook. Just follow the Wizard prompts.
 
Back
Top