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

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
153
Office Version
  1. 2016
Platform
  1. Windows
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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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
Back
Top