timer re-opening spread sheet when other spreadsheets are open

Footballtend

New Member
Joined
Apr 13, 2021
Messages
5
Office Version
  1. 2013
Platform
  1. Windows
Hello,
I am not very familiar with VB, but doing some research I was able to get some code to make a timer that will let people know they have been in the workbook for 15 minutes by a message box. This is a shared spreadsheet. A few people have said that they will open the spread sheet, make changes, Save and close the workbook in under 15 minutes. Then when the 15 minutes elapses, the workbook will reopen. It only does this when there is another workbook open. Code is below. I did some digging but I cant seem to find the error.

I have this code in its entirety in "ThisWorkBook" and also is a Module.

-------------------------------------------
Option Explicit



Dim DownTime As Date

Sub workbook_open()

Call SetTimer

End Sub

Sub SetTimer()

DownTime = Now + TimeValue("00:15:00")

Application.OnTime EarliestTime:=DownTime, Procedure:="MsgBoxCriticalIcon", Schedule:=True

End Sub

Sub StopTimer()

On Error Resume Next

Application.OnTime EarliestTime:=DownTime, Procedure:="MsgBoxCriticalIcon", Schedule:=False

End Sub

Public Sub MsgBoxCriticalIcon()

MsgBox "Please close the file if no longer in use.", vbCritical

End Sub
----------------------------------------------------------------
If anyone could help it would be appreciated.

Thank you,
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

ZVI

MrExcel MVP
Joined
Apr 9, 2008
Messages
3,818
Office Version
  1. 2016
  2. 2010
  3. 2007
Platform
  1. Windows
Glad that worked for you & thanks for the feedback! :)
 

Watch MrExcel Video

Forum statistics

Threads
1,130,042
Messages
5,639,723
Members
417,107
Latest member
derekMG

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