I'm trying to call built-in functions (as in Excel VBA) and can't get it to work. Based on examples I gather I need to do something like this:
Function calc_Func(sFunc$,args())
dim oFA as Object
oFA = createUNOService("com.sun.star.sheet.FunctionAccess")
calc_Func = oFA.callFunction(sFunc,args())
end function
Function test(x as double) as double
test =calc_Func("NORMSDIST",x())
End Function
However, when I call test(0.5) I get "Basic runtime error. Object variable not set." with the arrow pointing to the line "calc_func = ofa.callFunction".
How does this work? Thanks.
Bob
Calling a built-in function
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: Calling a built-in function
Hi,
You must transmit an array of argument(s)
______
Bernard
You must transmit an array of argument(s)
Code: Select all
test =calc_Func("NORMSDIST", Array(x))
Bernard
Re: Calling a built-in function
Thanks very much!
Since I had trouble finding a *simple* working example, I will post my working test cases. I hope if there is anything wrong or misleading here someone will correct me.
Function calc_Func(sFunc$,args())
dim oFA as Object
oFA = createUNOService("com.sun.star.sheet.FunctionAccess")
calc_Func = oFA.callFunction(sFunc,args())
end function
' a function with one parameter
Function test(x) as double
test =calc_Func("NORMSDIST",array(x))
End Function
' a function with three parameters
Function test2(xval as double,mu as double,sig as double) as double
test2=calc_Func("STANDARDIZE",Array(xval,mu,sig))
end function
Since I had trouble finding a *simple* working example, I will post my working test cases. I hope if there is anything wrong or misleading here someone will correct me.
Function calc_Func(sFunc$,args())
dim oFA as Object
oFA = createUNOService("com.sun.star.sheet.FunctionAccess")
calc_Func = oFA.callFunction(sFunc,args())
end function
' a function with one parameter
Function test(x) as double
test =calc_Func("NORMSDIST",array(x))
End Function
' a function with three parameters
Function test2(xval as double,mu as double,sig as double) as double
test2=calc_Func("STANDARDIZE",Array(xval,mu,sig))
end function