Date: prev next · Thread: first prev next last
2025 Archives by date, by thread · List index


Bonjour Bernard,

bonne année 2025 !

Le 03/01/2025 à 11:31, Bernard Siaud alias Troumad a écrit :

J'ai un fichier de travail que je peux transmettre ici dans lequel je souhaitais utiliser la fonction round (https://help.libreoffice.org/latest/fr/text/sbasic/shared/03170000.html).

Pour utiliser cette macro, il faut rajouter en début de fichier macro :

Option VBASupport 1 Si je le fais, j'ai une erreur qui apparait plus lors de l'appel d'une fonction personnelle (il souhaite un "=" lors de l'appel). Cet égal n'a rien à faire à ce niveau.

Et si tu nous montrais le code incriminé, in extenso ?

En passant : LibO version ? Version système ?

PS : tu peux utiliser les fonctions du tableur au moyen d'un appel à l'API ("com.sun.star.sheet.FunctionAccess").

8< --------------------------------------------------
Function RunSpreadsheetFunction(ByRef pFuncName As String, pArrParams() As Variant) As Variant
'returns the result of a spreadsheet function execution.
'Input:
'-- pFuncName: the spreadsheet function name (EN version only) (ex: "AVERAGE") '-- pArrParms(): an array containing all parameters for the function execution.
'                See the Calc help to know which information to store there.
'Output: a variant value with the result of the function execution or NULL if something went wrong.
'
'Example: MATCH function
'RowIndex = RunSpreadsheetFunction("MATCH", Array(Criterion, Vector, Option))
'where
'-- Criterion: the data used as a criterion, type matching the one in the vector
'-- Vector: the vector in which to match
'-- option: the search option (for more information, see Calc help)
'returns the row index where the data matches the criterion.

        Dim l_Result As Variant
        Dim l_FuncName As String
        Dim lo_Func As Object           'the calc function access object

        l_Result = NULL
        l_FuncName = UCase(Trim(pFuncName))
        If (l_FuncName <> "") Then
                lo_Func = CreateUnoService("com.sun.star.sheet.FunctionAccess")
                
                On Local Error Resume Next
                l_Result = lo_Func.callFunction(l_FuncName, pArrParams())
        End If
        
        RunSpreadsheetFunction = l_Result
End Function 'RunSpreadsheetFunction
--------------------------------------------- >8

Utilisation avec ROUND() (utiliser les noms de fonctions EN) :

Resultat = RunSpreadsheetFunction("ROUND", Array(2.56, 1))


Amicalement,
--
Jean-Francois Nifenecker, Bordeaux
07.52.63.25.54

--
Envoyez un mail à users+unsubscribe@fr.libreoffice.org pour vous désinscrire
Les archives de la liste sont disponibles à https://listarchives.libreoffice.org/fr/users/
Privacy Policy: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.