Setting the Length of Time a File Can Stay Open
This code closes the file after a period of inactivity
Option Explicit
Private Sub Workbook_Open()
nElapsed = TimeSerial(0, 5, 0) '5 minutes
'start a timer to countdown inactivity
Application.OnTime Now + nElapsed, "Countdown"
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
'any workbook activity resets the timer
Application.OnTime nTime, "Countdown", , False
nTime = Now + nElapsed
Application.OnTime nTime, "Countdown"
End Sub
'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
and in a standard code module
Option Explicit
Public nElapsed As Double
Public nTime As Double
Sub Countdown()
ThisWorkbook.Close
End Sub
--
__________________________________
HTH
Bob
"MDS" wrote in message
...
sIs it possible to set the length of time you can keep a workbook open
for?
I have several people updating a single file and oftentimes they leave it
open on their desktop - thereby preventing others from updating it. I
would
like to set the amount of time a file can be open for so that other's can
access it.
Any ideas?
Thanks.
|