+ Reply to Thread
Results 1 to 6 of 6

Application.OnTime Not Working for me

  1. #1
    Registered User
    Join Date
    03-27-2013
    Location
    Apple Valley, MN
    MS-Off Ver
    Excel 2010
    Posts
    5

    Application.OnTime Not Working for me

    What I would like to do is automatically run a macro that displays a reminder (message box) to save and close the workbook the user is in by 3:40pm (assuming they have it open). Here is the code I'm using:
    Sub SetAlarm()
    Application.OnTime TimeValue("03:40:00"), "DisplayAlarm"
    End Sub

    Sub DisplayAlarm()
    MsgBox "Please Save and Close Your Workbook by 3:40pm!"
    End Sub
    I can't get this to work at all! The Sub DisplayAlarm works if I run it manually so I know that's not the problem. I haven't been able to successfully get the Application.OnTime event to run at all. I've tried testing it with various times and it doesn't seem to do anything. I don't understand why it wouldn't work for me. I'm using Excel 2010 on Windows 7 Enterprise Service Pack 1.

    Please help! Thanks!

    Trey

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: Application.OnTime Not Working for me

    3:40pm would be

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-27-2013
    Location
    Apple Valley, MN
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Application.OnTime Not Working for me

    I knew I would make a typo in posting my thread. Regardless...ignore the time in the first sample I gave. I was testing the code this morning and I couldn't get it to work. Here is a better example of what I was experimenting with this morning:

    Sub SetAlarm()
    Application.OnTime TimeValue("09:55:00"), "DisplayAlarm"
    End Sub

    Sub DisplayAlarm()
    MsgBox "Please Save and Close Your Workbook by 10:00am!"
    End Sub

    This wasn't working at all. I would watch my windows clock go strike 9:55:00 am and nothing would happen. (I kept the file open)

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: Application.OnTime Not Working for me

    Please Login or Register  to view this content.
    I just used the following and it worked as expected.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: Application.OnTime Not Working for me

    does the help version work for you ?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-27-2013
    Location
    Apple Valley, MN
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Application.OnTime Not Working for me

    No, that doesn't work for me either. I tried it:
    Sub SetAlarm()
    Application.OnTime Now + TimeValue("00:00:15"), "DisplayAlarm"
    End Sub

    Sub DisplayAlarm()
    MsgBox "Please Save and Close Your Workbook by 3:40pm!"
    End Sub
    I waited about 20 minutes and nothing happened. I'm not sure what to do now.

+ 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