detecting application idle time in Excel 2000

G

Guest

How can you program excel to detect idle time and use this to exit the
program after a set period of time.
 
G

Guest

Hi!

Try this idea.

Copy next 4 codes ThisWorkbook module.

'***********************************************************
Private Sub Workbook_Open()
On Error Resume Next
Application.OnTime RunSubProgram, "SaveAndClose", , False
On Error GoTo 0
RunSubProgram = Now + TimeSerial(0, Minutes, 0)
MsgBox ("Application exit, if you don't use it " & vbCrLf & _
Minutes & " minutes!"), , "Warning!"
Application.OnTime RunSubProgram, "SaveAndClose", , True
End Sub
'***********************************************************
Private Sub Workbook_SheetChange(ByVal Taulukko As Object, ByVal Kohde As
Range)
On Error Resume Next
Application.OnTime RunSubProgram, "SaveAndClose", , False
On Error GoTo 0
RunSubProgram = Now + TimeSerial(0, Minutes, 0)
Application.OnTime RunSubProgram, "SaveAndClose", , True
End Sub
'***********************************************************
Private Sub Workbook_SheetSelectionChange(ByVal Taulukko As Object, ByVal
Kohde As Range)
On Error Resume Next
Application.OnTime RunSubProgram, "SaveAndClose", , False
On Error GoTo 0
RunSubProgram = Now + TimeSerial(0, Minutes, 0)
Application.OnTime RunSubProgram, "SaveAndClose", , True
End Sub
'***********************************************************
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime RunSubProgram, "SaveAndClose", , False
On Error GoTo 0
End Sub
'***********************************************************
And copy next codes Module1
'***********************************************************
Public RunSubProgram As Double
Public Const Minutes = 15

Public Sub SaveAndClose()
ThisWorkbook.Close SaveChanges:=True
End Sub
'***********************************************************
Regards,
Kari J Keinonen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top