Opening a protected view workbook stops my timer that is is running in another opened workbook

Indominus

Board Regular
Joined
Jul 11, 2020
Messages
160
Office Version
  1. 2016
Platform
  1. Windows
Hello. So I have a workbook that tracks break times. It does this by counting down from 20 minutes in column E when a value is entered in column A. It is updated every single second. However, when a workbook that is in Protected View and needs to have "Enable editing" selected opens then I get run time error 91, "Object variable or with block variable not set" under the line

ActiveSheet.Range("E3").Calculate

After this the timer will not work on this workbook unless both files are closed and the protected view is removed. How could I edit these codes to remove the protected view and keep calculating the active sheet. Or just identify the sheet that needs the second by second calculation which is titled "Track Break Times.?"

Here are my module codes and then my private subs saved in the workbook
VBA Code:
Sub UpdateTime()
    ActiveSheet.Range("E3").Calculate
    Call Timer
End Sub

Sub Timer()
    Application.OnTime Now + TimeValue("00:00:01"), "UpdateTime"
End Sub

Sub StopTimer()
On Error Resume Next

Application.OnTime Now + TimeValue("00:00:01"), "UpdateTime", Schedule:=False

End Sub






Private Sub Workbook_Open()

UpdateTime

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)


Call StopTimer

End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try calling UpdateTime in the Workbook_Activate event handler instead of Workbook_Open
 
Upvote 0

Forum statistics

Threads
1,223,883
Messages
6,175,168
Members
452,615
Latest member
bogeys2birdies

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