I'm trying to make a function in VBA that calls a process. I have two processes, one that takes no parameters, and one that takes 1 parameter, so I need a setup that will handle both scenarios. Here is what I have right now.
Code: Select all
Public Function Execute_Process(strServerName As String, strProcessName As String, bParams As Boolean, ParamArray aParams()) As String
Some Stuff happens here to make sure there's a connection, etc...
Dim vaParams As Long
If bParams Then
Dim hHandle() As Long
ReDim hHandle(UBound(aParams))
Dim i As Integer
For i = 0 To UBound(aParams)
If VarType(aParams(i)) = vbString Then
hHandle(i) = TM1ValString(hPool, aParams(i), Len(aParams(i)))
Else
hHandle(i) = TM1ValReal(hPool, aParams(i))
End If
Next i
vaParams = TM1ValArray(hPool, hHandle, UBound(hHandle))
Else
Dim lArray(0) As Long
vaParams = TM1ValArray(hPool, lArray, 0)
End If
Dim hResult As Long
hResult = TM1ProcessExecute(hPool, hProcess, vaParams)
If (TM1ValBoolGet(hUser, hResult) = False) Then
Execute_Process = "Error: Process Executed with Errors"
Exit Function
End If
Execute_Process = ""
End Function
Any Ideas?