Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto saving & closing file prtcorvette Excel Worksheet Functions 1 May 21st 08 10:06 PM
How to code on Macro on saving and closing a file? Eric Excel Worksheet Functions 1 June 10th 07 01:32 PM
Sri NEED HELP - AUTO MAILING THE FILE WHILE CLOSING Sriram Excel Programming 2 August 11th 06 10:45 AM
skipping pop up box for saving changes when closing a file Tony Excel Programming 1 October 1st 04 07:49 PM
closing a file without saving matt dunbar Excel Programming 3 November 25th 03 06:29 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"