set time limit before closing sheet

M

Maria Johansson

Hello,

I have a xls-file used by several people and I wish this
file to be automatically closed after an hour.
Any suggestions?

Thanks, Maria
 
N

Nick Hodge

Maria

Not sure how reliable this would be, it might have issues if a user is
editing a cell when the code runs, but this will shut down the workbook
after 1 hour from opening. The top code goes in the ThisWorkbook module and
the bottom code in standard module. Post back for help on placing this.

The first code fires when the workbook is opened which runs the second code
after 1 hour. It saves the workbook. You may wish to refine it by adding
warnings to users, etc!


Private Sub Workbook_Open()
Application.OnTime EarliestTime:=Now() + TimeValue("01:00"),
Procedure:="ShutDown"
End Sub

Sub ShutDown()
ThisWorkbook.Close SaveChanges:=True
End Sub
 
Top