LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default 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.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting to automatically open a source file by double clicking on Russ Setting up and Configuration of Excel 1 January 12th 09 10:31 PM
Setting a row to stay on top timmyc New Users to Excel 2 August 3rd 07 06:43 PM
When i open excel file it takes time to open Muraliraj Menon Excel Discussion (Misc queries) 1 May 23rd 07 12:50 PM
Can Excel open a new application every time you open a file? shoon Setting up and Configuration of Excel 0 December 13th 05 03:28 PM
How do I stop Excel from closing the open file each time I open a. Welsin Setting up and Configuration of Excel 3 January 8th 05 11:16 PM


All times are GMT +1. The time now is 08:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"