ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close Open Woorkbook and Quit Excel (https://www.excelbanter.com/excel-programming/286113-close-open-woorkbook-quit-excel.html)

Lucy[_2_]

Close Open Woorkbook and Quit Excel
 
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


KJTFS[_2_]

Close Open Woorkbook and Quit Excel
 
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


---
Message posted from http://www.ExcelForum.com/


Lucy[_2_]

Close Open Woorkbook and Quit Excel
 
Thanks, but what starts this sub at 11 PM?

Lucy

-----Original Message-----
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


---
Message posted from http://www.ExcelForum.com/

.


KJTFS[_3_]

Close Open Woorkbook and Quit Excel
 
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


---
Message posted from http://www.ExcelForum.com/


Lucy[_2_]

Close Open Woorkbook and Quit Excel
 
And the function "ontime" is what I am looking for! Once
I get it, then rest is relatively easy.

Lucy

-----Original Message-----
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


---
Message posted from http://www.ExcelForum.com/

.


KJTFS[_6_]

Close Open Woorkbook and Quit Excel
 
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
---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com