Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto saving & closing a file after inactivity
Hello:
I would appreciate help with this one: What code do I need to place in "Workbook Open" so that after 10 minutes of no activity, the file is automatically saved and closed. TIA Vinay |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto saving & closing a file after inactivity
See http://vbaexpress.com/kb/getarticle.php?kb_id=516 for a method tha includes changing the right-click menu and using a password. For your purposes this simplified version should suffice. Code ------------------- '<< START OF CODE FOR THISWORKBOOK MODULE 'http://vbaexpress.com/kb/getarticle.php?kb_id=516 Private Sub Workbook_Open() Run "StartTimer" End Sub Private Sub Workbook_SheetCalculate(ByVal Sh As Object) Run "DisableTimer" Run "StartTimer" End Sub Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) Run "DisableTimer" Run "StartTimer" End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Run "DisableTimer" Run "StartTimer" End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Run "DisableTimer" End Sub '<< END OF CODE FOR THISWORKBOOK MODULE '<< START OF CODE FOR REGULAR MODULE 'http://vbaexpress.com/kb/getarticle.php?kb_id=516 Public IdleTime As Date Sub StartTimer() IdleTime = Now + TimeValue("00:10:00") Application.OnTime IdleTime, "SaveAndClose" End Sub Sub DisableTimer() On Error Resume Next Application.OnTime EarliestTime:=IdleTime, _ Procedu="SaveAndClose", Schedule:=False End Sub Sub SaveAndClose() With ThisWorkbook .Save .Close End With End Sub '<< END OF CODE FOR REGULAR MODULE ------------------- -- skatonn ----------------------------------------------------------------------- skatonni's Profile: http://www.officehelp.in/member.php?userid=418 View this thread: http://www.officehelp.in/showthread.php?t=120318 Posted from - http://www.officehelp.i |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
auto saving & closing file | Excel Worksheet Functions | |||
How to code on Macro on saving and closing a file? | Excel Worksheet Functions | |||
Sri NEED HELP - AUTO MAILING THE FILE WHILE CLOSING | Excel Programming | |||
skipping pop up box for saving changes when closing a file | Excel Programming | |||
closing a file without saving | Excel Programming |