Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default closing excel after 5 mins idle

Can anyone help me:

I have built a spreadsheet that my team of 5 use regularly. If someone
has it open then others can't use it. sometimes ppl forget to close
it.

Is there any way I can tell MS Excel to save the worksheet and close
it after 5 or 10mins idle?

Thanks,
MB
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default closing excel after 5 mins idle

Hi Mack,

I have built a spreadsheet that my team of 5 use regularly. If someone
has it open then others can't use it. sometimes ppl forget to close
it.

Is there any way I can tell MS Excel to save the worksheet and close
it after 5 or 10mins idle?


You could consider sharing the workbook, but I discourage sharing Excel
workbooks because it is unreliable.

To your question:

There is no "activity timer" built into Excel, but we can use the ontime
method to schedule a closure of the workbook and reschedule the set time
at all of Excel's built in workbook events.

Open the VBE and insert a normal module, paste in this code:

'-------------------

Option Explicit

Public dNextTime As Double

Sub SetNewTimer()
ResetTimer
'adjust the time below to your needs, this is 10 minutes
dNextTime = Now + TimeValue("00:10:00")
Application.OnTime dNextTime, "CloseMe"
End Sub
Sub ResetTimer()
Application.OnTime dNextTime, "CloseMe", False
End Sub
Sub CloseMe()
ThisWorkbook.Close SaveChanges:=True
End Sub

'-------------------

Now open the Thisworkbook module and paste this code:

'-------------------

Option Explicit

Private Sub Workbook_Activate()
SetNewTimer
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ResetTimer
End Sub

Private Sub Workbook_BeforePrint(Cancel As Boolean)
SetNewTimer
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
SetNewTimer
End Sub

Private Sub Workbook_Deactivate()
SetNewTimer
End Sub

Private Sub Workbook_NewSheet(ByVal Sh As Object)
SetNewTimer
End Sub

Private Sub Workbook_Open()
SetNewTimer
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
SetNewTimer
End Sub

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)
SetNewTimer
End Sub

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal
Target As Range, Cancel As Boolean)
SetNewTimer
End Sub

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
SetNewTimer
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
SetNewTimer
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
SetNewTimer
End Sub

Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal
Target As Hyperlink)
SetNewTimer
End Sub

Private Sub Workbook_SheetPivotTableUpdate(ByVal Sh As Object, ByVal
Target As PivotTable)
SetNewTimer
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
SetNewTimer
End Sub

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
SetNewTimer
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
SetNewTimer
End Sub

Private Sub Workbook_WindowResize(ByVal Wn As Window)
SetNewTimer
End Sub

'-------------------


Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

Reply
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
detecting idle time salmosalar Excel Discussion (Misc queries) 0 February 2nd 07 05:25 PM
how can i convert a value quoted in hrs,mins,secs to just mins The man from delmonte Excel Worksheet Functions 1 October 17th 06 11:12 AM
Excel 12, er, 2007 - Semi-idle Curiosity Harlan Grove Excel Worksheet Functions 7 May 30th 06 10:33 AM
Adding minutes showing total in hours/minutes, i.e., 60 mins + 60 mins + 15 mins to total of 2 hours 15 mins? StargateFan Excel Discussion (Misc queries) 8 January 7th 06 07:35 PM
How to convert numeric value to mins and addimg mins to Hrs. ramana Excel Worksheet Functions 1 October 28th 05 10:42 AM


All times are GMT +1. The time now is 02:21 PM.

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

About Us

"It's about Microsoft Excel"