I really don’t know why you are “wrapping” all of the Calc functions with your own code. It seems to me off hand that it would be more advised to create good Named Ranges and use a few nested built-in functions within the spreadsheet itself than to go about creating a set of UDF function names in BASIC. What I see here is, first, you had Arg, not Args on your Svc call, and second, you are trying to index ThisComponent.Sheets(), which I don’t think it likes. Use ThisComponent.Sheets.getByName(“parts”)…
Here is working code:
Function SingleDrawerContents(RefCell as Variant) As Variant
SingleDrawerContents = GetPartByID(RefCell)
End Function
Function GetPartByID(Id as Integer) As Variant
Dim CellRange As Object
'CellRange = ThisComponent.Sheets("parts").getCellRangeByName("A:L")
CellRange = ThisComponent.Sheets.getByName("parts").getCellRangeByName("A:L")
'MRI CellRange
GetPartByID = VLookUp2(Id, CellRange, 5)
End Function
Function VLookUp2(SearchValue as Variant, Range as Object, Index as Integer)
Dim Svc
Dim Args
Svc = CreateUnoService("com.sun.star.sheet.FunctionAccess")
Args = Array(SearchValue, Range, Index, False)
VLookUp2 = Svc.CallFunction("VLOOKUP", Args)
End Function
I’d mention in passing, also, that you ought to be using Option Explicit (which would have caught the Arg(s) problem), and MRI 1.3.4 - someone might correct me, but I believe the link is https://github.com/hanya/MRI/releases.