Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes, with the OnTime method. The following would run the sub called MySub at
2:45 pm: Application.OnTime TimeValue("14:45:00"), "MySub" -- - K Dales "sd" wrote: Can a macro be set up to run at a specific time? I have a macro I want to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Application.OnTime (..... -- Kaak ------------------------------------------------------------------------ Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513 View this thread: http://www.excelforum.com/showthread...hreadid=489389 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the application.ontime command. eg....
Application.OnTime TimeValue("14:58:00"), "your_macro_name" -- Cheers Nigel "sd" wrote in message oups.com... Can a macro be set up to run at a specific time? I have a macro I want to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Open your excel, open with Alt-F11 the visual basic editor, Open Help
look for method: OnTime. Put the code + My_Procedure in the personal macro book. some examples : My_procedure will start after 15 seconds from now Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure" or at 17.00 Application.OnTime TimeValue("17:00:00"), "my_Procedure" or to cancel it: Application.OnTime EarliestTime:=TimeValue("17:00:00"), _ Procedu="my_Procedure", Schedule:=False I think this can do the trick. Good luck with it. Let me know if it's working. grtx's Martijn "sd" schreef in bericht oups.com... Can a macro be set up to run at a specific time? I have a macro I want to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've taken a different approach... Create the macro as an Auto_Open() macro,
or invoke it on the Workbook_Open event. Then set up the Excel file containing the macro as a Windows Scheduled Task. "sd" wrote: Can a macro be set up to run at a specific time? I have a macro I want to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good approach but your macro starts only when you open the workbook not on a
certain time. You are right when you say "if excel is not open than the other macro's don't work also" grtx's Martijn "bpeltzer" schreef in bericht ... I've taken a different approach... Create the macro as an Auto_Open() macro, or invoke it on the Workbook_Open event. Then set up the Excel file containing the macro as a Windows Scheduled Task. "sd" wrote: Can a macro be set up to run at a specific time? I have a macro I want to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The task scheduler allows me to indicate when the workbook should be opened
and, therefore, when the macro runs. So Excel doesn't need to be running; it's kicked off at the designated time by the scheduler. "Martijn" wrote: Good approach but your macro starts only when you open the workbook not on a certain time. You are right when you say "if excel is not open than the other macro's don't work also" grtx's Martijn "bpeltzer" schreef in bericht ... I've taken a different approach... Create the macro as an Auto_Open() macro, or invoke it on the Workbook_Open event. Then set up the Excel file containing the macro as a Windows Scheduled Task. "sd" wrote: Can a macro be set up to run at a specific time? I have a macro I want to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Won't you have a problem if the workbook is already open?
Gordon Rainsford bpeltzer wrote: The task scheduler allows me to indicate when the workbook should be opened and, therefore, when the macro runs. So Excel doesn't need to be running; it's kicked off at the designated time by the scheduler. "Martijn" wrote: Good approach but your macro starts only when you open the workbook not on a certain time. You are right when you say "if excel is not open than the other macro's don't work also" grtx's Martijn "bpeltzer" schreef in bericht ... I've taken a different approach... Create the macro as an Auto_Open() macro, or invoke it on the Workbook_Open event. Then set up the Excel file containing the macro as a Windows Scheduled Task. "sd" wrote: Can a macro be set up to run at a specific time? I have a macro I want to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. -- Gordon Rainsford London |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sure; there are trade-offs everywhere. My approach fails if the workbook is
open; the other fails if it isn't. But since I typically schedule these things to run overnight, having the files open isn't usually an issue. Besides, the macro files are special-purpose and wouldn't normally be open except when I want them to run. And I love coming arriving at work with lots of my reports already completed ;-) "Gordon Rainsford" wrote: Won't you have a problem if the workbook is already open? Gordon Rainsford London |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you haven't looked at Chip Pearson's notes about OnTime, you may want to
review them: http://www.cpearson.com/excel/ontime.htm sd wrote: Can a macro be set up to run at a specific time? I have a macro I want to run if it is 2:58pm can this be done? I think excel needs to be open in order to do this but I am not sure if a macro can run with out an actual event. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro / function text time to 24hr excel time passed midnight fortotaling hr's | Excel Worksheet Functions | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Worksheet Functions | |||
time and auto macro run by setting time | Excel Programming | |||
Help with Macro to Convert Date/Time to Time Only | Excel Programming | |||
excel - macro - automatic initiation of a macro at a pre-specified "system time" | Excel Programming |