API: Prime 7 - Excel. Matrix passing issues.
Hi,
I managed to pass variables from Excel to Prime 7 and then back to Excel using Visual Basic. The code works as intended. Here is the code
Private Sub CommandButton2_Click()
Dim a, b, c As Integer
Dim RowNum As Integer
Dim Path As String
Dim MC As Ptc_MathcadPrime_Automation.Application
Dim WS As Ptc_MathcadPrime_Automation.Worksheet
Path = CurDir & "\" & ActiveSheet.Range("J4").Value
a = ActiveSheet.Range("C2").Value
b = ActiveSheet.Range("C3").Value
c = ActiveSheet.Range("C4").Value
Set MC = CreateObject("MathcadPrime.Application")
MC.Visible = True
Set WS = MC.Open(Path)
WS.SetRealValue "a", a, ActiveSheet.Range("D2").Value
WS.SetRealValue "b", b, ActiveSheet.Range("D3").Value
WS.SetRealValue "c", c, ActiveSheet.Range("D4").Value
WS.Synchronize
Set RawOut = WS.OutputGetRealValue("out")
ActiveSheet.Range("C7").Value = RawOut.RealResult
ActiveSheet.Range("D7").Value = RawOut.Units
End Sub
The issue arises when I try to pass multiple variables (100+) using an array or matrix. Meaning, taking an array or Matrix of size (n,1) from excel, add it to a variable in Prime (lets say, M), then using the elements of M to populate the Prime file and retrieving the output back to Excel.
Somehow, when I jump from single values to matrices my code crashes.
I found this thread
where the OP seems to have the same issue. I tried all the solutions there but I keep getting errors. I can't even define a matrix using
Set matrix = WS.CreateMatrix(3, 3)
As one anon did.
Anyone has any idea how to do this?
Thank you!

