我试图从LibreOffice基本宏调用IRR函数,但得到一个
非法论据异常
Function Bla()
Dim oFunc as Object
oFunc = createunoservice("com.sun.star.sheet.FunctionAccess")
Dim args(1) as Variant
args(0) = Array(3300, -1000, -2000)
args(1) = 0.1
Dim vResult as Variant
vResult = oFunc.callFunction("IRR", args)
Print vResult
End Function
调用该函数的正确方法是什么?
答案 0 :(得分:0)
显然,这些函数需要一个二维数组。
Sub CallIRR()
Dim oFunc As Object
oFunc = createUnoService("com.sun.star.sheet.FunctionAccess")
Dim args(1) As Variant
args(0) = Array(Array(3300, -1000, -2000))
args(1) = 0.1
Dim vResult As Variant
vResult = oFunc.callFunction("IRR", args)
Print vResult
End Sub
为了解决这个问题,我在https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Function_Handling#Calculating_Function_Results处使用了Java示例。
修改强>: