ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Timer Code (https://www.excelbanter.com/excel-programming/379178-re-timer-code.html)

Bob Phillips

Timer Code
 
Add this to a general module

Option Explicit

Public nTime As Double

Public Sub closemedown()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub


and then add this to ThisWorkbook

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime nTime, "closemedown", , False
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
nTime = Now + TimeSerial(1, 30, 0)
Application.OnTime nTime, "closemedown"
End Sub

Private Sub Workbook_Open()
nTime = Now + TimeSerial(1, 30, 0)
Application.OnTime nTime, "closemedown"
End Sub

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Al" wrote in message
...
Hello
I am having a problem with a file being left open and I would like code to
automatically close the file after 90 minutes after the last change on any
page in the wb with changes saved before the close.
Can this be done? How?
Thanks





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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com