Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Timed closing code questions
If by "flag" you mean the reference in the VBA Project to the WSH library,
that setting is saved within the workbook itself. If you use the workbook on any other machine, WSH will be loaded automatically when the workbook opens. You don't need to manually set the reference yourself. -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "Mike K" wrote in message ... 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... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Timed closing code questions
Awesome, Thanks Chip!
"Chip Pearson" wrote: If by "flag" you mean the reference in the VBA Project to the WSH library, that setting is saved within the workbook itself. If you use the workbook on any other machine, WSH will be loaded automatically when the workbook opens. You don't need to manually set the reference yourself. -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "Mike K" wrote in message ... 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... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2 Questions about the following code - Please help if you can. | Excel Programming | |||
Closing Workbook without Questions | Excel Programming | |||
Closing Code | Excel Programming | |||
Closing the VBA Editor using code | Excel Worksheet Functions | |||
[HELP] closing a program with VBA code | Excel Programming |