+ Reply to Thread
Results 1 to 2 of 2

Timer Countdown then close

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

    Timer Countdown then close

    hi i am struggling with what code i need to have a countdown then close function in this document.
    i need the time to show in label2 in userform1 , i need a 5 minute timer counting down to 0 then save and close the document
    this is to make sure that users dont leave the document open so others cant access it

    i have had a suggestion from Lieth Ross


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

    Sub StartTimer()
    Application.OnTime Now() + TimeValue("00:05:00"), "TimeExpired"
    End Sub

    Sub TimeExpired()
    ThisWorkbook.Close SaveChanges:=True
    Application.Quit
    End Sub



    i dont know how to call the code

    can anyone help me with this please
    Attached Files Attached Files
    Last edited by Chris Wareham; 11-01-2011 at 05:32 PM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Timer Countdown then close

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ 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