cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Mathcad Prime 8 API - Passing an array of strings from Mcad to Excel

PEAH
12-Amethyst

Mathcad Prime 8 API - Passing an array of strings from Mcad to Excel

Hi all

I am using Visual Basic for Application in Excel and am trying to pass an array of strings from Excel to Prime 8 through the API. I have managed to pass a matrix/array of numbers, but if I change the matrix content to strings, the OutputGetMatrixValue object fails with Errorcode = 7, suggesting "Matrix result is invalid." See Figure.png and below code.

 

It appears not possible from the help documentation, see Figure2.png. Alternatively, I could convert the strings to unicode numbers, and then pass them to Excel through the below code, and then convert them back to strings. Or use a text file?

 

Any suggestions for the easiest way forward?

 

'Get a matrix value
Set out2 = ws.OutputGetMatrixValue("out2")
Dim q As Variant
RowCount = out2.MatrixResult.Rows
colCount = out2.MatrixResult.Columns
ReDim q(RowCount - 1, colCount - 1)
For i = 0 To RowCount - 1
For j = 0 To colCount - 1
d = out2.MatrixResult.GetMatrixElement(i, j, dblhere)
q(i, j) = dblhere
Debug.Print "q(" & i & "," & j & ") = " & CStr(q(i, j))
Next j
Next i

ACCEPTED SOLUTION

Accepted Solutions
PEAH
12-Amethyst
(To:PEAH)

Hi all

 

I found a work-around, converting the strings to unicode numbers in Mcad, pass it to Excel through OutputGetMatrixValue and convert unicode numbers back to strings in Excel.

View solution in original post

1 REPLY 1
PEAH
12-Amethyst
(To:PEAH)

Hi all

 

I found a work-around, converting the strings to unicode numbers in Mcad, pass it to Excel through OutputGetMatrixValue and convert unicode numbers back to strings in Excel.

Announcements

Top Tags