View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mike K Mike K is offline
external usenet poster
 
Posts: 104
Default Timed closing code questions

Oh Wise Ones,

Heres a bit of code from Jim Thomlinson that saves and closes a workbook
after a set amount of time, but prompts the user for some more time. Works
great. I have 2 questions though.

1) If multiple people share a computer, will the Windows Script Host Object
Model flag be present for ALL people on that PC if it is set by the first
person?

2) I and not a programmer, but I would guess that the Windows Script Host
Object Model flag is set in the registry. Instead of running around to 30+
computers, can I package this in a reg file and email it out?


Sub Auto_Open()
Application.OnTime Now() + TimeValue("00:00:20"), "CloseMe"
End Sub

'requires reference to "Windows Script Host Object Model"
Public Sub CloseMe()
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long

Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Are you still there?", secondstowait:=2, _
Title:="Active", Type:=vbYesNo)
If Res = vbYes Then
Application.OnTime Now() + TimeValue("00:00:20"), "CloseMe"
Else
ThisWorkbook.Save
ThisWorkbook.Close
End If
End Sub

--
HTH...