Results 1 to 2 of 2

Timer Countdown then close

Threaded View

  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.

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