Macros: A simple clock
Here is another simple macro that turns an OOo Calc spreadsheet into a real time clock.
The OpenOffice Basic builtin function Now returns the current date and time as a Date value. By embedding this function inside an infinite WHILE loop, we simulate a clock. The code is shown below.
Sub DisplayTime
Dim oDoc As Object
Dim oSheet As Object
Dim oCell As Object
Dim oDoc As Object
Dim oSheet As Object
Dim oCell As Object
oDoc=ThisComponent
oSheet=oDoc.Sheets.getByName(”Sheet1″)
) oCell=oSheet.getCellByposition(1,1) ‘B2
Do
oCell.SetString(Now)
Wait 1000
Loop While 1
End Sub
The output to the spreadsheet is shown below.
