To get by with a single line in such cases, I set up the very simple module below (Standard.aaaGlobal for me). Of course, this module may get enriched with some additional functionality.
The names for global use are rather long. I deliberately chose them this way to avoid accidental conflicts.
Code: Select all
REM ***** BASIC *****
Global globalCalcFunctionAccess As Object
REM This object should not be dirtectly accessed by user code.
REM It must be expected to not be initiaized.
Function gFunctionAccess()
REM This function MAY be directly used AS IF it is a FunctionAccess service.
If IsNull(globalCalcFunctionAccess) Then globalCalcFunctionAccess = _
CreateUNOService("com.sun.star.sheet.FunctionAccess")
gFunctionAccess = globalCalcFunctionAccess
End Function
Function gCallCalcFunction(pName As String, pParams)
REM This function provides support for Calc functions under Basic.
gCallCalcFunction = gFunctionAccess.callFunction(pName, pParams)
End Function
Code: Select all
useAsDate = gCallCalcFunction("TEXT", Array( _
gCallCalcFunction("DATE", Array(2000, 0, 1111)), _
"YYYY-MM-DD"))