Free Layer macro to get the current date + 14 days in a cell

advertisements

I need to get todays date + 14 days string formatted in standard dd.mm.yyyy format into Libre Office calc cell.

I already tried the code below, but I lack the knowledge to cope with "Object variable not set" error.

REM  *****  BASIC  *****

sub Datumplus14
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
Dim cell as object
dim term as date
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
term = today()
cell.String = DateAdd("d", 14, datum)

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, cell)

end sub

Different ideas on how to get this done instead of macro is welcome as well.


Hmm, not sure if this will answer the specifics of what you're actually trying to do, but you can easily get the current date and just +14 to it directly in a cell formula.

Like so:

=NOW()+14

The rest is just applying the required date format to that cell. You can also grab the date from another cell too.