function CDateToUnoDateOOAndLO(d as Date) as com.sun.star.util.Date
dim dd as new com.sun.star.util.Date
with dd
.month= month(d)
.day = day(d)
.year = year(d)
CDateToUnoDateOOAndLO = dd
end with
end function
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
The date field value looks to be a long though (as per RoryOF's link) - so scrap that - instead you'll need to test for whether its LO or OO and use CDateToIso if its OO.
There's a lot of divergence between OO and LO in dialog controls now.
How to make this code works in both LibreOffice and OpenOffice?
I suggest you to install the LibreOffice (same version on all of the related computers).
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
if TypeOf Dlg.getControl("DateField").Date is com.sun.star.util.Date Then
' Code for LibreOffice
Dlg.getControl("DateField").Date = CDateToUnoDate(Date())
Else
' Code for OpenOffice
Dlg.getControl("DateField").Date = CDateToIso(Date())
End If
Thanks.
OpenOffice 4.1.14 on Windows 7 and LibreOffice 6.4.7.2 on Linux Mint 20.3