Hi folks,
i´m working on a Sheet with a Dialog and Macros for it.
I´ve come across an interesting thing. E.g.:
i created a timefield. Despite im typing wrong timeformats into the fields like “18”, it shows “18:00”. Thats great, since its supposed to be a timefield with only correct timeformats in it. (Yes Formatting check is enabled on the field)
BUT: If i try to save the incorrect entry into my sheet it will save the wrong format (not showed on the timefield). Here´s the code:
REM ***** BASIC *****
Dim oDialog_new_entry As Object
Sub Main()
DialogLibraries.LoadLibrary("Standard")
oDialog_new_entry = CreateUnoDialog(DialogLibraries.Standard.new_entry)
oDialog_new_entry.Execute()
oDialog_new_entry.dispose()
End Sub
Sub save_entry()
ctl_date = oDialog_new_entry.GetControl("ctl_date")
ctl_time = oDialog_new_entry.GetControl("ctl_time")
cell_date = ThisComponent.Sheets(0).getCellRangeByName("A2")
cell_time = ThisComponent.Sheets(0).getCellRangeByName("B2")
cell_date.string = ctl_date.text
cell_time.string = ctl_time.text
oDialog_new_entry.endexecute()
End Sub
Sub abort_entry()
oDialog_new_entry.endexecute()
End Sub
Same goes for the Datefield, but its not that painfull since the Datefield will accept few less harder formatmistakes.
My suggestion is its something with the Cell.String / Control.text . But i cant find any hints for the controlfields to get the Time in the control instead of the Text in the control.
Maybe u can help me <3<3
I attached the file if u want to try. Keep in mind to directly type in one number like “13” or “22” and click somewhere so the timefield will format it´s entry. Then press Save.
timedatenew.ods
LibreOffice Version 6.1.3.2(x64)