Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Timer to detect idle time?

If no changes are made to my workbook after
5 minutes, I want to autosave and close the
workbook. Is something like this possible?

thank you


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Timer to detect idle time?

Hi,

Yes that's possible with code.

These get pasted into 'ThisWorkbook'

Private Sub Workbook_Open()
Call SetDelay
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call Disable
End Sub

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Call Disable
Call SetDelay
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)
Call Disable
Call SetDelay
End Sub

Right click 'ThisWorkbook' insert module and paste this in

Dim DownTime As Date

Sub SetDelay()
DownTime = Now + TimeValue("00:05:00") 'change time as needed
Application.OnTime DownTime, "CloseBook"
End Sub

Sub CloseBook()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=DownTime, _
Procedu="CloseBook", Schedule:=False
End Sub

Save and close the workbook and on reopening 5 minutes of inactivilty will
cause it to save and close.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Robert Crandal" wrote:

If no changes are made to my workbook after
5 minutes, I want to autosave and close the
workbook. Is something like this possible?

thank you


.

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
Question on VBA : how to detect "idle" condition Daniel[_18_] Excel Programming 2 November 4th 07 06:34 PM
Time calculation (Subraction of Idle Time) Ajay Excel Discussion (Misc queries) 6 March 4th 07 11:54 AM
detecting application idle time in Excel 2000 salmosalar Excel Programming 0 February 3rd 07 03:30 AM
detecting idle time salmosalar Excel Discussion (Misc queries) 0 February 2nd 07 05:25 PM
Detecting user idle time R Avery[_2_] Excel Programming 1 May 3rd 05 06:34 PM


All times are GMT +1. The time now is 01:32 AM.

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"