Close Open Woorkbook and Quit Excel

  • Thread starter Thread starter Lucy
  • Start date Start date
L

Lucy

I need to shut down open Excel workbooks at 11 PM to
start data update. These workbooks can be opened on
different PC's and as such, I need to include in these
workbooks code similar to On Timer event in Access. I
have found following OnTime event, but now need a trigger
to start it.

If Format(Now(), "Medium Time") = Format
("23:00:00, "Medium Time") Then
Application.OnTime Now + TimeValue
("00:0:05"), "Quit_Workbook"
End If

Perhaps there is a better way to do this as I am not too
familiar with Excel programming.

Any help or resource is greatly appreciated. Thanks.

Lucy
 
You will want a function like this, to run on the ontime.

Sub QuitApp()

Application.setwarnings false
ThisWorkbook.Save ''Might need to change if you have multiple WBs
open
Application.quit

End Sub


Keith
www.kjtfs.com
 
O I thought you had your ontime event running.

have a function in the workbookopen event that calls the ontime which
will call the quit function.

Keith
www.kjtfs.com
 
And the function "ontime" is what I am looking for! Once
I get it, then rest is relatively easy.

Lucy
 
I have attached a file that closes 5 seconds after you open it. I think
this is what you are looking for. Change the code to 23:00:00 on the
ontime event and it will close at 11. The ontime event is in the
workbookopen event. To look at the code disable macros when you open
the book so it doesn't close when you are looking at it. Hope this
helps.


Keith
www.kjtfs.com

Attachment filename: quitappwb.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=390287
 
Back
Top