Consulting

Results 1 to 8 of 8

Thread: Countdown timer for writing

  1. #1
    VBAX Newbie
    Joined
    May 2020
    Posts
    5
    Location

    Countdown timer for writing

    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!

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,117
    Location
    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
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    VBAX Newbie
    Joined
    May 2020
    Posts
    5
    Location
    THANK YOU!!!!! This is amazing!!!! I appreciate it so much!!!!

  4. #4
    VBAX Newbie
    Joined
    May 2020
    Posts
    5
    Location
    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!

  5. #5
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,117
    Location
    KTK. KTK stands for your "Key to the kingdom"
    Greg

    Visit my website: http://gregmaxey.com

  6. #6
    VBAX Newbie
    Joined
    May 2020
    Posts
    5
    Location
    You are amazing! I appreciate it so much!!!!

  7. #7
    VBAX Newbie
    Joined
    May 2020
    Posts
    5
    Location
    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

    cws pic.JPG

  8. #8
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,117
    Location
    Click here to start.docm

    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
    Greg

    Visit my website: http://gregmaxey.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •