built-in function function min Kohei Yoshida Paolo Mantovani

To use Calc's built-in functions in Basic macro, you need to first create a service object of {@link com.sun.star.sheet.FunctionAccess}, and call the method "callFunction". Arguments are passed to this method as an array object even if there is only one argument. If the argument is a cell range, a cell range object must first be created, and passed into an array object before it is injected into the callFunction method (see the example code).

Sub callFunction svc = createUnoService( "{@see com.sun.star.sheet.FunctionAccess}" ) ' Calculate min of numbers. arg = array( 10, 23, 5, 345 ) print svc.callFunction( "MIN", arg ) ' Calculate min of values in cell range A1:A17 oSheet = ThisComponent.Sheets(0) ' Get leftmost sheet oCellRange = oSheet.getCellRangeByPosition( 0, 0, 0, 16 ) 'A1:A17 arg = array( oCellRange ) print svc.callFunction( "MIN", arg ) End Sub
Initial version added platform&version informations and auto-IDL linking