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
Bookmarks