PDA

View Full Version : How to Pause a PowerPoint Timer : My Wonky Method



Kellaroo
03-06-2022, 10:00 PM
I'm trying to find a way of pausing a timer that uses input from a textbox.
If there is a way of making a pause directly with VBA then that would solve my problem immediately, but I don't know how to do that (I need a 'pause' to work indefinitely, not specified for 10sec).

My way of doing this is to have the 'pause button' make visible another textbox that copies the value of the timer textbox. Then I can re-input that value to resume the countdown.
For example, if the timer states 00:01:30 at the time of pressing the pause button, then the copied timer will read 00:01:30.
Now I can take that value later and re-input it into the timer, effecting a pause/ resume.
My problem is that the timer won't take input in the form of hh:mm:ss, and if I remove the colons it won't translate well (i.e. 1:30 becomes 130, which is understood as 130 seconds instead of 90 seconds).

Hopefully that ^ can be understood. It's difficult to put words on the exact problem. Here is the code and the PPT where you can see the problem in action.

How can I make this code accept the hh:mm:ss format as input, instead of a seconds integer?


Sub countdown()


Dim time As Date
time = Now()


Dim count As Integer
count = ActivePresentation.Slides(1).Shapes("TimeLimit").TextFrame.TextRange


time = DateAdd("s", count, time)


Do Until time < Now()
DoEvents
ActivePresentation.Slides(1).Shapes("countdown").TextFrame.TextRange = Format((time - Now()), "hh:mm:ss")
Loop


End Sub


I see the solution being something like:
1. An entirely different way to pause a countdown with VBA
2. A way to make this countdown timer receive input in the format of hh:mm:ss
3. A way to convert the hh:mm:ss format back into seconds integer

Any of these things would effectively fix my problem.
Thank you for your consideration!

Kellaroo
03-08-2022, 10:44 PM
I think I figured out a way of making this work.
I take the value that comes off the clock at the time of pause (copying time to another textbox)
Then I isolate the hours and multiply by 3600, and isolate the minutes and multiply by 60, and add them all together with the isolated seconds.
This gives me an integer for the total amount of seconds to re-input into the clock, so as to resume the countdown where the pause had left it.
If anyone else has this problem let me know, and I'll try to explain in detail.
I'm sure it's not the cleanest/ most efficient way though.
But... It is working : )