I have created (oh I mean copied) code to have a timer close my workbook after 3 minutes of inactivity. However, the timer is locking up all the other code I worked so diligently to create (uh....copy). Please take a look. Where am I going wrong? (oh....I'm only like 1-2 weeks into being a VBA user....so be kind)
In "This Workbook"
Private Sub Workbook_Open()
StartTimer
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
StartTimer
End Sub
In "Module x"
Const idleTime = 300 'seconds
Dim Start
Sub StartTimer()
' ===========
' This will make the file close (no save) after the idle time listed above
' ===========
Start = Timer
Do While Timer < Start + idleTime
DoEvents
Loop
Application.DisplayAlerts = False
' *************
' Don't forget to change name of workbook below
' *************
Workbooks("TestArea-Data collection tool.xlsm").Close SaveChanges:=False
End Sub
I don't get an error when this locks up my other code. Everything just kinda stops. And so my impatient self closes and starts over. All my other code is in a userform. I can post that if it's needed. But it works flawlessly until I turn on the timer coding (above) on. THANKS!
Bookmarks