Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Close excel when inactive


Hi,

I would like to have excel close after 15min of being inactive (n
button / mouse clicks, no data entered, etc) however it may still b
the active workbook.

If possible I would like it to bring up a message box that say
something along the lines of:

"About to close, click Cancel to stop." and clicking cancel would kee
the workbook open until it had been inactive for another 15 mi
period.

Does anyone know how to do this?

Thanks
Jenni

--
jenni
-----------------------------------------------------------------------
jennie's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=49067

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Close excel when inactive

You could use Ontime together with worksheet change event code to monitor
it.


There are 5 elements here.


Firstly have a macro which invokes Ontime to run a macro that shutdown in 15
minutes. And you also need a macro to reset the timer . SO, in a standard
code module, add

Option Explicit


Public nShutdown As date

Public Sub SetShutdownTimer()
nSaveWB = Now + TimeSerial(0, 15, 0) ' 15 minutes
Application.OnTime nShutdown, "Shutdown"
End Sub


Public Sub Shutdown()
Dim ans
ans = MsgBox"About to close, click Cancel to stop.", vbOKCancel)
If vbOK Then
Application.Quit
Else
SetShutdownTimer
End If
End Sub

You then need to set the timer in the first place, when the workbook opens.
And you also need to trap any workbook changes , and any worksheet
selectione, so that the timer gets cancelled, and set anew (note this
doesn't
reset the timer for any formatting changes, only data changes).


Option Explicit


Private Sub Workbook_Open()
SetShutdownTimer
End Sub


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.OnTime nShutdown, "Shutdown", , False
SetSaveWBTimer
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range) Application.OnTime nShutdown, "Shutdown", , False
SetSaveWBTimer
End Sub



'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"jennie" wrote in
message ...

Hi,

I would like to have excel close after 15min of being inactive (no
button / mouse clicks, no data entered, etc) however it may still be
the active workbook.

If possible I would like it to bring up a message box that says
something along the lines of:

"About to close, click Cancel to stop." and clicking cancel would keep
the workbook open until it had been inactive for another 15 min
period.

Does anyone know how to do this?

Thanks
Jennie


--
jennie
------------------------------------------------------------------------
jennie's Profile:

http://www.excelforum.com/member.php...fo&userid=6706
View this thread: http://www.excelforum.com/showthread...hreadid=490678



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Close excel when inactive


Thanks a lot

I will give it a try

Thanks
Jennie


--
jennie
------------------------------------------------------------------------
jennie's Profile: http://www.excelforum.com/member.php...fo&userid=6706
View this thread: http://www.excelforum.com/showthread...hreadid=490678

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Close excel when inactive


I think it should be:

ans = MsgBox("About to close, click Cancel to stop.", vbOKCancel)

(missing a bracket)

Also, when I try to run the code, I get:

nSaveWB (variable not defined)

and also, after trying to run "Public Sub Shutdown"

I get "Only comments may appear after End Sub ..."

All the code is in the worksheet's property, is that what's intended?


--
Benoit Lamarche


"Bob Phillips" wrote:

...
Public Sub Shutdown()
Dim ans
ans = MsgBox"About to close, click Cancel to stop.", vbOKCancel)
If vbOK Then
Application.Quit
Else
SetShutdownTimer
End If
End Sub


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
excel menu inactive Tushar Excel Discussion (Misc queries) 1 May 10th 06 05:40 AM
Option in Excel to save a close a workbook inactive for 5 minutes Patricia Peterson Excel Discussion (Misc queries) 4 January 5th 06 05:00 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM
Inactive close Dave Hardy Excel Programming 1 August 12th 03 03:11 PM


All times are GMT +1. The time now is 01:13 AM.

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"