+ Reply to Thread
Results 1 to 21 of 21

Closure on timer coundown

  1. #1
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Closure on timer coundown

    Hi Folks, would it be possible for you to help me

    what im trying to do is create a countdown timer from 5 minutes and when the time is up close the excel application completey, is this possible if so does anyone have the code to do the countdown too. Regards Chris

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    Copy and paste this code into a module in your VBA project. Call StartTimer from your code when needed. After five minutes have passed the macro TimeExpired will run. This will first close the workbook and save any changes and then close Excel.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    Hi Leith thanks for the reply, i am an absolute beginner and it probably wont come as a suprise but i am thick lol could you explain to me how i call this function or where and how i call it i have put this code into a module called module 2 but not sure on how to call it, i need it to show in my label2 if that makes sense, i could upload the code for you to see if its any easier, thanks Chris
    this countdown needs to start on userform load up
    Last edited by Chris Wareham; 10-31-2011 at 07:01 PM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    If you post your workbook, I will add the macros in. You can download the updated workbook and see what I have done. It will make a lot sense than if I try to walk you through the process.

    To Attach a File:
    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

  5. #5
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    http://www.excelforum.com/excel-prog...-coundown.html
    hi Leith the above link should do the trick.....
    thanks chris

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    I have made the necessary changes to the attached workbook and tested it. Here is the routine that was added to the UserForm. No other code was needed.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    that worked at treat thanks [SOLVED]

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    Here is the updated code for the timer. It counts down from 5 minutes. Replace the code in your User Form with this version.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    Leith there seems to be a problem with the application.quit part because when i load the workbook up it shuts straight back down again and if i remove the application.quit part it counts down perfect but keeps on counting down minus lol.
    Last edited by Leith Ross; 11-03-2011 at 02:00 PM.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    This is totally weird. I will look into this more. Not sure if the workbook may be corrupt or if it might be a bug.

  11. #11
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    How's it looking Leith? Has it fraggled your head yet lol

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    My search for a possible bug has not helped. I haven't had time to rebuild the workbook to test the corruption theory. Have you discovered anything?

  13. #13
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    i shall try to re create the workbook then give you an update. . .

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    Good luck, I hope it works.

  15. #15
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    Leith i have tried and recreated another workbook but had the same issue, i have managed to find the error but not sure how to work around it.
    If Timer >= TimeOut Then
    it seems o be the operators that cause the problem especially the less than operator, if i remove it then it counts down and continues going minus, soon as i add it again it closes the entire workbook so i cant see anything

  16. #16
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    WTF? What version of Windows and Office are you using?

  17. #17
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    Hi Leith, i'm using windows vista home premium and office 2007 but the workbook is saved as a 97-2003 document, would that still be a problem

  18. #18
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    Sorry Vista home basic

  19. #19
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    Vista has lots of problems, so I not surprised by this is not working. I don't own Vista because it was a Windows release like Windows ME. Neither should have ever been released.

    I really don't know where to go from here. However, I would strongly suggest you purchase Windows 7 as soon as possible. It is much more stable than Vista and has good backward compatibility. Vista's whole intent was to break the reliance on backward compatibility. It succeeded.

  20. #20
    Registered User
    Join Date
    10-28-2011
    Location
    Staffordshire
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Closure on timer coundown

    Great tip Leith, i do need an upgrade so will look at this soon, what i will do in the mean time is forward the code to work which is running on xp and office 97-2003, i will see if it works and let you know , like i said before i would like to thank you for your time, there should be some kind of donation service available to support the good work your doing, i will keep you posted yet again lol

  21. #21
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Closure on timer coundown

    Hello Chris,

    If the workbook is rebuilt on Windows XP and Office 2003 there should not be any issues.

+ 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