Extension. Formula works in cells but not in macros. Special action?

Hey, thank you for LibreOffice and your time.

I use a scientific extension on LibreOffice 7.3 (for Excel and Python, but installed with a wrapper for LibreOffice)

Formulas work fine in cell.

I try to use this same formula in BASIC (according to editor snippets) and I have the error

BASIC runtime error
Sub-procedure or function procedure ar not defined
Additional information: PropSI

‘PropSI’ is the formula which works fine in formula :slight_smile:

Ma question is,
Do I do a special action for making an extension, which works in formula, works in BASIC macros ?

The extension is Coolprop (http://coolprop.org)

Code Example…

Option VBASupport 1

REM  *****  BASIC  *****
' Ne fonctionne pas, erreur 35 ; Not defined
'Changer les guillements

Sub Test1_1()
	'density of Nitrogen at 101325 Pa & 300 K
'	Dim D1 as Variant
	D1 =PropsSI("D", "P", 101325, "T", 300, "Nitrogen")
	Print D1 & " kg/m^3"     '1.13816468646245 kg/m^3
	'order of input properties is irrelevant
	D2 = PropsSI("D", "T", 300, "P", 101325, "Nitrogen")
	Debug.Print D2 & " kg/m^3"     '1.13816468646245 kg/m^3

End Sub

Thank you for your time :).

José from France.

You didn’t mention the hidden process of obtaining the extension :wink:

1 Like

Yes, thank you to remind this
You can see my thank post :slight_smile: (I am jrd10)

I can mention this too. The documentation I have found which is accessible if you are not a thermodynamician or an expert in BASIC :).

CoolProp creates its functions in org.coolprop.wrappers.libreoffice.CalcAddIn service. Please see this help page to learn how to access Calc functions from Basic code (specifically, add-in ones), changing the respective names accordingly.

1 Like

Thank you, it seems to me you provided the solution…
I have already seen this help and I though… “It’s not for me :)”.

I didn’t understand what is a ‘UNOService’

But I will try :).

Thank you again.

FTR: this works:

  oService = createUNOService("org.coolprop.wrappers.libreoffice.CalcAddIn")
  msgbox oService.Props1SI("R410A","Tcrit")

Thank you again @mikekaganski, it works

REM  *****  BASIC  *****

Sub CoolProp_LOMacro

Dim vPropsSI 		As Variant
Dim vProps1SI 	        As Variant

  oService = createUNOService("org.coolprop.wrappers.libreoffice.CalcAddIn")

   vProps1SI = oService.Props1SI("R410A","Tcrit")
   vPropsSI = oService.PropsSI("C", "T", 28815, "P", 101325, "Nitrogen")   ' =PROPSSI("C"; "T"; A2; "P"; B2; C2)

MsgBox "CoolProp Functions:" & CHR$(13) &  "vProps1SI (R410A)   : " & vProps1SI & CHR$(13) & "vPropsSI (Nitrogen): " & vPropsSI

End Sub