If a function is called by a FunctionAccess object the actual parameters (even if only 1) are always passed as an array. You have to write
T_pm = svc.callfunction("MAX", Array(oCellRange.Data))
.
However, I am afraid you will not get what you expext as soon as there is a (at least one) cell in the range not containing a number and there is no positive value in the range.
For each cell originally empty or containing text the array property oCellRange.Data
will contain a number of format Double, namely 2.2250738585072E-308
which is specified to represent NAN (not a number) for Calc. Max will nonetheless treat it as a number and therefore return this as the result under the above mentioned conditions.
I do not know how Calc is handling this if calling MAX for a formula evaluation. The evaluator surely has to preprocess the parameter(s) somehow. There will be a routine for it in the core code. (Do you know that the parameters of MAX are not specified as a list of arrays but as NumberSequenceList
in OpenFormula documents?)
As I love full control and (technical) explicitness anyway I would prefer writing a MyMAX function in BASIC over workarounds using standard MAX.