Auto Close Excel Workbook

  • Thread starter Thread starter MBlake
  • Start date Start date
M

MBlake

Hi,
I need to ensure that a user has closed their Excel Workbook. I have added
the following code and Excel will do this but insists on asking the user to
click a messagebox OK button to note the system is closing. Is there a way
around this so that Excel will close even if a user is not there?. The
workbook contains other code to ensure all changes are saved after input
(via a userform) so I have no need to save the file prior to closing it.
The user is made aware when they open the Workbook that it will
automatically close after 30 minutes, hence I just need to be able to shut
it down remotely when a user has gone home and inadvertently left the file
open.

Thanks,
Mickey
========================================================
--- Module Code ---

Private Sub KillTheApp()
'
'
ThisWorkbook.Close savechanges:=False 'true ???
End Sub
========================================================
--- Workbook Code ---

Application.OnTime Now + TimeValue("00:30:00"), "KillTheApp"
========================================================
 
One possible alternative is the DisplayAlerts property of the Application
object in Excel. I cannot guarantee it will work in your situation, but it
is one option you may want to look into.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


Hi,
I need to ensure that a user has closed their Excel Workbook. I have added
the following code and Excel will do this but insists on asking the user to
click a messagebox OK button to note the system is closing. Is there a way
around this so that Excel will close even if a user is not there?. The
workbook contains other code to ensure all changes are saved after input
(via a userform) so I have no need to save the file prior to closing it.
The user is made aware when they open the Workbook that it will
automatically close after 30 minutes, hence I just need to be able to shut
it down remotely when a user has gone home and inadvertently left the file
open.

Thanks,
Mickey
========================================================
--- Module Code ---

Private Sub KillTheApp()
'
'
ThisWorkbook.Close savechanges:=False 'true ???
End Sub
========================================================
--- Workbook Code ---

Application.OnTime Now + TimeValue("00:30:00"), "KillTheApp"
========================================================
 
Back
Top