+ Reply to Thread
Results 1 to 11 of 11

Run a macro at a cretin time of day

  1. #1
    sd
    Guest

    Run a macro at a cretin time of day

    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. #2
    Forum Contributor
    Join Date
    03-24-2004
    Location
    Edam Netherlands
    Posts
    181
    Application.OnTime (.....

  3. #3
    K Dales
    Guest

    RE: Run a macro at a cretin time of day

    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.
    >
    >


  4. #4
    Nigel
    Guest

    Re: Run a macro at a cretin time of day

    Use the application.ontime command. eg....

    Application.OnTime TimeValue("14:58:00"), "your_macro_name"

    --
    Cheers
    Nigel



    "sd" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #5
    Martijn
    Guest

    Re: Run a macro at a cretin time of day

    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"), _
    Procedure:="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" <[email protected]> schreef in bericht
    news:[email protected]...
    > 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. #6
    bpeltzer
    Guest

    RE: Run a macro at a cretin time of day

    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. #7
    Martijn
    Guest

    Re: Run a macro at a cretin time of day

    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" <[email protected]> schreef in bericht
    news:[email protected]...
    > 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. #8
    bpeltzer
    Guest

    Re: Run a macro at a cretin time of day

    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" <[email protected]> schreef in bericht
    > news:[email protected]...
    > > 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. #9
    Gordon Rainsford
    Guest

    Re: Run a macro at a cretin time of day

    Won't you have a problem if the workbook is already open?

    Gordon Rainsford


    bpeltzer <[email protected]> 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" <[email protected]> schreef in bericht
    > > news:[email protected]...
    > > > 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. #10
    bpeltzer
    Guest

    Re: Run a macro at a cretin time of day

    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. #11
    Dave Peterson
    Guest

    Re: Run a macro at a cretin time of day

    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1