View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Sandy Mann Sandy Mann is offline
external usenet poster
 
Posts: 2,345
Default "Kicking Out" Inactive Users

Paul,

Excelent code whoever wrote it. I tried it at work in XL 2002, (we also
have one bloody minded individual who leaves a common workbook open), one
drawback is that if the bloody minded individual does not dismiss the
messagebox then the code does not run.

I tried using a Jim Rech Sub that Dave Peterson posted some time ago:

Start of Dave's post
***************************************
This was posted by Jim Rech to a similar request:

If you have the Windows Scripting Host Obj model installed (WSHOM.OCX), and
I believe it's part of Windows 98 among other things, you can run this:


Sub SelfClosingMsgBox()
CreateObject("WScript.Shell").Popup "Hello", 2, _
"This closes itself in 2 seconds"
End Sub


And if you wanted to be able to check to see if they hit ok or cancel:


Sub SelfClosingMsgBox2()
Dim Resp As Long
Resp = CreateObject("WScript.Shell").Popup("Hello", 2, _
"This closes itself in 2 seconds", vbOKCancel)
'MsgBox Resp
If Resp = vbCancel Then
MsgBox "cancel was hit"
End If


End Sub
*****************************************

End of Dave's post

I tried it both as a separate Sub that was called from the Workbook_Open()
and as just the line of code in the Workbook_Open() (both times before the
SetTime procedure is called), but although the Sub works on its own in an
empty Workbook, it hangs until manually dismissed when used with the other
code.

mmmmm.... I may just have to take him by surprise <g
--
Regards,

Sandy
In Perth, the ancient capital of Scotland


with @tiscali.co.uk


"Paul B" wrote in message
...
Mike, not sure where I got this code but this should get you started

this will auto-close the workbook after 20 seconds of inactivity

'***************************************

'put this in a standard module

Dim DownTime As Date



Sub SetTime()

DownTime = Now + TimeValue("00:00:20")

Application.OnTime DownTime, "ShutDown"

End Sub



Sub ShutDown()

ThisWorkbook.Save

ThisWorkbook.Close

End Sub



Sub Disable()

On Error Resume Next

Application.OnTime EarliestTime:=DownTime, Procedu="ShutDown",
Schedule:=False

End Sub

'*******************************************

'************************************

'put this in thisworkbook

Private Sub Workbook_Open()

MsgBox "This workbook will auto-close after 20 seconds of inactivity"

Call SetTime

End Sub



Private Sub Workbook_BeforeClose(Cancel As Boolean)

Call Disable

End Sub



Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

Call Disable

Call SetTime

End Sub



Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range)

Call Disable

Call SetTime

End Sub

'*****************************


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003



"Mike The Newb" wrote in message
...
I have a file that only allows one user at a time to have write/update
authority (first one in locks it up); there are five people with this
modification authority. The problem is one of them opening it and then
walking away for an extended period of time and thus the others cannot
input
their updates. I do not want to make it into a shared file.

Similar to my company's auto password protected screen saver (kicks on
after
"x" number of inactive minutes), I would to have the file save itself and
close if a write/update user hasn't navigated in the file via keyboard or
mouse in say the last three minutes. Ideally, anyone who opened the file
with
"read only" clearance (approximately a dozen users preset as Read Only)
would
not get "kicked out" as they are not disrupting anyone.

Any clues / insight?

Regards,
Mike