LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Code to automatically close an Excel spreadsheet

I'm using code I found in an earlier email thread to save/close a workbook
after 1 minute, after prompting the user to see if he/she is still there
(resets the timer if Yes is clicked).

The code works fine as long as the user has exited out of a data field. But
if the user has entered data in a field but hasn't clicked out of it, the
wkbook stays open as it would if the code weren't there.

1) How can I force it to exit the field, save whatever has been entered &
close?

2) I would also like to add a countdown message to the "Are you there?"
prompt (i.e. "If you do not click Yes, this workbook will close in <#
seconds"). How can I do that?

The code being used is below:

In Thisworkbook:

Private Sub Workbook_Open()
Application.OnTime Now() + TimeValue("00:01:00"), "CloseMe"
End Sub

In a New Module:

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:=3, _
Title:="Doc Tracking List Check", Type:=vbYesNo)
If Res = vbYes Then
Application.OnTime Now() + TimeValue("00:01:00"), "CloseMe"
Else
ThisWorkbook.Save
ThisWorkbook.Close
End If
End Sub

--
Thanks for your help!
JoAnn
 
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
save and close automatically an excel spreadsheet PRAV Excel Programming 1 September 5th 06 01:37 AM
I want to close down excel after 1 hour automatically blitzz Excel Programming 2 May 3rd 06 07:36 PM
Is there a way to insert a formula, password or macro in an excel spreadsheet that will automatically delete the spreadsheet? oil_driller Excel Discussion (Misc queries) 1 February 8th 05 09:34 AM
Automatically Close Excel Greg[_15_] Excel Programming 1 August 18th 04 02:46 PM
VBA code to automatically close file Kevin Excel Programming 4 November 6th 03 04:18 PM


All times are GMT +1. The time now is 08:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"