Close Workbook Programmatically

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

Lucy

I need to shut down open Excel workbooks at specific time
(e.g. 1 AM) to start data upload. This code will be
included with every workbook that must be closed before
the upload starts (the workbooks reside on a network
drive, but may stay open on different PC's due to users
no closing them, etc.).

Does anybody know the code or point me to a resource to
the trigger this update at the selected time?

Thanks for your help.

Lucy
 
I don't know of an easy way to do this.
The complicated way would probably involve checking the file system for who
has open locks, then killing their open locks. It could get messy.

You could maintain copies, ie. users work on a user file, uploads work on
the upload files.
 
I think it is not really that difficult. All I need is a
trigger to start running the following sub (that will be
included in the workbook) at the selected time.

Sub Quit_Workbook()
With Application
.DisplayAlerts = False
.ThisWorkbook.Close False
.Quit
End With
End Sub

It's the trigger I am looking for that will shut down the
app at 1 AM without any user intervention (in MS Access I
can accomplish that with On Timer event).

I have the following code, but again I need another code
(trigger) to start this without anybody's intervention:

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

Do you know how the trigger this?

Thanks.

Lucy
-----Original Message-----
I don't know of an easy way to do this.
The complicated way would probably involve checking the
file system for who has open locks, then killing their
open locks. It could get messy.
You could maintain copies, ie. users work on a user
file, uploads work on the upload files.
 
You might have success with Application.OnTime TimeValue("17:00:00"),
"my_Procedure"
 
Back
Top