PDA

View Full Version : Countdown timer for writing



Mwhyman2
05-20-2020, 10:33 AM
Hello. I am a teacher trying to navigate the online world. I need to create a document that has a 3 minute countdown timer. I want my kids to be able to click a start button and then complete a timed writing. Once the time is up I need them to be notified so they stop working. I have watched a few VBA videos and I think I am close to figuring it out. But any and all help would be great!

gmaxey
05-20-2020, 12:15 PM
You could let them OPEN a document that contains the following two macros:


Sub AutoOpen()
If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect "KTK"
ActiveDocument.Range.Text = vbNullString
MsgBox "This is a timed 3 minute writing exercise." & vbCr + vbCr _
& "Clickg ""OK"" to begin.", vbOKOnly, "TIMED EXERICSE"
Application.OnTime Now + TimeValue("00:03:00"), "Notify"
End Sub

Sub Notify()
MsgBox "It is time to stop."
ActiveDocument.Protect wdAllowOnlyReading, , "KTK"
End Sub

Mwhyman2
05-20-2020, 12:46 PM
THANK YOU!!!!! This is amazing!!!! I appreciate it so much!!!!

Mwhyman2
05-20-2020, 03:50 PM
This could be silly, but when it says password protected, what's the password if I need to make an edit? :)

This is the most amazing thing though. Thank you so much!

gmaxey
05-20-2020, 03:56 PM
KTK. KTK stands for your "Key to the kingdom"

Mwhyman2
05-20-2020, 04:03 PM
You are amazing! I appreciate it so much!!!!

Mwhyman2
05-20-2020, 10:39 PM
Can I bother you one more time, please?! :) Sorry!

I am so close to getting it just right and I had it for a minute, I swear. But now I can't get it to let me type once I click the timer on. This is what I have so far. Once I added the command button I screwed up the protection. How do I add the protection back so that I can write on the doc once I click start and then once the time is up it locks the editing? Thanks for your help. This is going to make all the difference for my special ed kids and their progress monitoring.

Private Sub Starttimer_Click()MsgBox "This is a timed 3 minute writing exercise." & vbCr + vbCr _
& "Click ""OK"" to begin.", vbOKOnly, "TIMED WRITING"
Application.OnTime Now + TimeValue("00:03:00"), "Notify"


End Sub
Sub Notify()
MsgBox "STOP! STOP! STOP!" & vbCr + vbCr _
& "-----" & vbCr + vbCr _
& "Save & Send to Whyman!!", vbOKOnly, "Congrats! You finished!"
ActiveDocument.Protect wdAllowOnlyReading, , "KTK"
End Sub

26712

gmaxey
05-21-2020, 07:22 AM
26715

The code has to be in the ThisDocument module of the project. See attached. I added a 15 seconds warning which you can keep or take out.


Option Explicit

Private Sub StartTimer_Click()
MsgBox "This is a timed 3 minute writing exercise." & vbCr + vbCr _
& "Click ""OK"" to begin.", vbOKOnly, "TIMED WRITING"
Application.OnTime Now + TimeValue("00:02:45"), "Warning"
'Application.OnTime Now + TimeValue("00:03:00"), "Notify"
lbl_Exit:
Exit Sub
End Sub

Sub Warning()
Beep
Application.OnTime Now + TimeValue("00:00:15"), "Notify"
lbl_Exit: Exit Sub
End Sub
Sub Notify()
MsgBox "STOP! STOP! STOP!" & vbCr + vbCr _
& "-----" & vbCr + vbCr _
& "Save & Send to Whyman!!", vbOKOnly, "Congrats! You finished!"
ActiveDocument.Protect wdAllowOnlyReading, , "KTK"
lbl_Exit:
Exit Sub
End Sub