PDA

View Full Version : scheduling a macro a once a week



bhagya2340
01-13-2009, 02:20 PM
Hi,
I have a macro which is running fine. Now i want to schedule this marcro to run automatically on every friday at 2:30PM is this possible to schedule it like this. If so how. I dont want to use windows scheduling service.

I do have a bat file and a .vbs file for this macro which are used to start the macro without opening the excel sheet.

I dont know much about VBA or macros... so please be in detail..

Thanks!

georgiboy
01-13-2009, 02:39 PM
I have no knowledge of bat and .vbs but as long as you can call the macro "Time_Run" every time the workbook is opened it should work. The workbook will need to be either left open or opened before the time in question.

You could put the "Time_Run" macro in Workbook.Open event or turn it into an Auto_Run macro. Either way it will need to be run when you open the workbook.

Sub Time_Run()

If Weekday(Now()) = 6 Then
Application.OnTime TimeValue("14:30:00"), "my_Procedure"
End If

End Sub

Sub my_Procedure()

' your macro goes here

End Sub
To turn it into an Auto_Run macro it would need to look like this...

Sub Auto_Run()

If Weekday(Now()) = 6 Then
Application.OnTime TimeValue("14:30:00"), "my_Procedure"
End If

End Sub

Sub my_Procedure()

' your macro goes here

End Sub
Hope this helps