Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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
Solved! Go to Solution.
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.
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.