Ask Your Question

Revision history [back]

Number format codes are assigned dynamically based on used formats (including custom user formats) and languages, so using hard-coded codes is not good.

Please see this answer for how to get code for desired format at run time.

Number format codes are assigned dynamically based on used formats (including custom user formats) and languages, so using hard-coded hardcoded codes is not good.

Please see this answer for how to get code for desired format at run time.

Essentially, it is

dim oLocale    as object
oLocale = ThisComponent.CurrentController.GetViewCursor.CharLocale
dim nFmtId as Long
nFmtId = ThisComponent.NumberFormats.queryKey("MM/DD/YY", oLocale, False)
if nFmtId = -1 then
   nFmtId = ThisComponent.NumberFormats.addNew("MM/DD/YY", oLocale)
end if

Of course, you might want to use some hardcoded locale, if required.