openoffice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maciej Jaros <>
Subject Re: Static date
Date Tue, 30 Jul 2013 10:31:42 GMT
Ruben van Amelsvoort (2013-07-26 18:18):
> Greetings,
> I'm looking for a way in OpenOffice Calc to get the current date in a cell,
> but keep it that date too. So just the simple Date function doesnt work.
> For example, it has to show 26-07-2013 because thats todays date, but it
> still has to show 26-07-2013 tomorrow too. Is this possible? Thanks!
> Kind regards,
> Ruben van Amelsvoort

Add below to your macros and then add a button to your toolbar linked to 
that macro. Done. You now have a button that can insert current date.

rem ----------------------------------------------------------------------
rem     inserts current date to the selected cell
rem ----------------------------------------------------------------------
sub insert_now_date
     rem define variables
     dim document   as object
     dim dispatcher as object
     rem get access to the document
     document   = ThisComponent.CurrentController.Frame
     dispatcher = createUnoService("")

     dim args1(0) as new
     args1(0).Name = "StringName"
     args1(0).Value = Format(Date, "YYYY-MM-DD")

     dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, 
end sub
rem --------------

Note. By replacing ``Format(Date, "YYYY-MM-DD")`` with ``Time`` you can 
insert current time. Full date and time would be: ``Format(Date, 
"YYYY-MM-DD") +" "+ Format(Time, "HH:MM:SS")``


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message