Getting Outputs with API
Hello everyone.
I made the following function in VBA (Excel) to retrieve the value of the variable B from the mathcad file using the API.
The Variable is defined in the file with a unit i.e. B := 2 m
Public Function test2() As Double
Dim objApp As Ptc_MathcadPrime_Automation.Application
Set objApp = New Ptc_MathcadPrime_Automation.Application
Dim b As Ptc_MathcadPrime_Automation.WorksheetReadonlyOptions
Set b = objApp.CreateWorksheetReadonlyOptions
bb = b.SetOptionValue(WorksheetReadonlyOptionNames_RequestToUpdateInputsEnabled, 2)
Dim objCalc As Ptc_MathcadPrime_Automation.IMathcadPrimeWorksheet3
Set objCalc = objApp.OpenEx("C:\Users\kai.jakob\Desktop\Testo.mcdx", b)
Dim a As Ptc_MathcadPrime_Automation.IMathcadPrimeOutputResult
Set a = objCalc.OutputGetRealValue("(@LABEL VARIABLE B)")
Set a = objCalc.OutputGetRealValue("B")
aa = a.RealResult
aaa = a.Units
test2 = aa
objCalc.Close (SaveOption_spSaveChanges)
objApp.Quit (SaveOption_spDiscardChanges)
End Function
The output I get is:
Double: aa = -1.#IND
Unit: aaa = ""
Can anyone tell me what is wrong with those functions?

