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
----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem
----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem
----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "StringName"
args1(0).Value = Format(Date, "YYYY-MM-DD")
dispatcher.executeDispatch(document, ".uno:EnterString", "", 0,
args1())
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")``
Regards,
Nux.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@openoffice.apache.org
For additional commands, e-mail: users-h...@openoffice.apache.org