Countdown start upon opening of Workbook - close after 20 min.

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
83
Hi,

I presently have a workbook that numerous individuals can access but I need it the Workbook to automatically close after 20 minutes. I have entered coding and the workbook does close but regardless of the time I insert, it closes after 2 minutes

Private Sub Workbook_Open()
Application.OnTime DateAdd("n", 20, Now), "Thisworkbook.close_it"
End Sub


Sub Close_it()
ThisWorkbook.Close True
End Sub

what do I need to change so that it closes after 20 minutes and is it possible for a window to appear advising the person that they have 1 minute left until their session is closed?

thank you
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
Message box would prevent file from closing until user responds

In ThisWorbook module
Code:
Private Sub Workbook_Open()
    Application.OnTime Now + TimeValue("00:20:00"), "CloseMacro"
End Sub

In STANDARD module
Code:
Sub CloseMacro()
    ActiveWorkbook.Save
    ActiveWorkbook.Close False
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,985
Messages
5,767,443
Members
425,414
Latest member
chwein

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top