Gruppe
Dialog
Problem
Wie kann ich eine Arbeitsmappe automatisch schließen lassen, wenn der Anwender 1 Minute lang keinen Eintrag in einer UserForm-TextBox tätigt?
StandardModule: modMain
Public NextTime As Date, dteStart As Date
Sub Updateclock()
NextTime = Now + TimeValue("00:00:10")
Application.OnTime NextTime, "Updateclock"
If Time - dteStart > TimeSerial(0, 1, 0) Then Call StopClock
End Sub
Sub StopClock()
Application.OnTime NextTime, "Updateclock", , False
Unload frmAutomatic
ThisWorkbook.Close savechanges:=True
End Sub
Sub CallForm()
frmAutomatic.Show
End Sub
ClassModule: frmAutomatic
Private Sub txtEingabe_KeyUp( _
ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
dteStart = Time
End Sub
Private Sub UserForm_Activate()
dteStart = Time
Call Updateclock
End Sub