Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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...


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default 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
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
2 Questions about the following code - Please help if you can. Chris Lewis[_2_] Excel Programming 0 January 4th 07 10:10 AM
Closing Workbook without Questions John Viall[_2_] Excel Programming 3 June 24th 06 08:00 PM
Closing Code Brian Matlack[_45_] Excel Programming 0 January 13th 06 08:39 PM
Closing the VBA Editor using code Bony_Pony Excel Worksheet Functions 1 March 7th 05 08:14 PM
[HELP] closing a program with VBA code Andr? Palmela Excel Programming 2 October 21st 04 05:47 PM


All times are GMT +1. The time now is 07:57 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"