[Calc] Coundown Timer

Creating Extension - Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.

[Calc] Coundown Timer

Postby VBWizard » Sat May 14, 2016 5:20 pm

This is a working Timer for Calc, that counts down in seconds.
Note that the Initial Time and the displayed countdown are in cell M10; this can be changed to suit users preference, but note there are TWO points in the code to change:
Firstly the "m10" in line 5 and secondly, the "12,9" in line 22.

Code: Select all   Expand viewCollapse view
Sub Countdown()
   Doc = ThisComponent
   Sheet = Doc.Sheets(0)
   ' ** Get Limit
   strTime=Sheet.getCellRangeByName("m10").getString()  ' the 1st change point to use a different cell
   nNewTime= nStartTime
   Do Until nTime=0
       Do while nStartTime=nNewTime
         n NewTime=timer
   done ' you can get rid of this sub and put something more exciting in.
End Sub
Sub Update ()
   Doc = ThisComponent
   Sheet = Doc.Sheets(0)
   Cell = Sheet.getCellByPosition( 12,9)   ' the second change point
End Sub
Sub done()
   msgbox ("Out Of Time, Sorry",0,"Time UP")
End Sub
Last edited by VBWizard on Sun May 15, 2016 6:56 pm, edited 2 times in total.
OpenOffice 4.1.2 on Windows XP
Posts: 8
Joined: Sat May 14, 2016 5:05 pm

Re: Coundown Timer

Postby Villeroy » Sat May 14, 2016 5:48 pm

Simple countdown
(15.56 KiB) Downloaded 263 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Posts: 24652
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Coundown Timer

Postby VBWizard » Mon May 16, 2016 10:24 pm

Note: If using "option explicit", nNewTime and nStartTime should be declared as "long", not "integer", and really should be lNewTime and lStartTime.
OpenOffice 4.1.2 on Windows XP
Posts: 8
Joined: Sat May 14, 2016 5:05 pm

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 4 guests