 | OO-Snippets: Call built-in functionsCommons| Keywords | built-in function, function, min |
|---|
| Language | OOBasic |
|---|
| Application | Calc |
|---|
| Authors | Kohei Yoshida (initial)
Paolo Mantovani
|
|---|
| Supported Versions | 1.0.x 1.1.x 2.0.x |
|---|
| Supported OS | All |
|---|
| Question |
|
|---|
| Answer | To use Calc's built-in functions in Basic macro, you need to first create a service object of 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( "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
|
Changelog| Date | User | Modification |
|---|
| 2005-04-26 | kohei | Initial version | | 2005-05-17 | paolomantovani | added platform&version informations and auto-IDL linking |
|