Skip to main content
1-Visitor
April 4, 2014
Solved

MathCad Add-In for Excel: can not save result?

  • April 4, 2014
  • 15 replies
  • 5810 views

Hi,all

I create a mathcad object and use variable in0 to receive data from excel. I wirte a assignment statement in the document, ret:=in0. I save the object into a .xmcd file and reopen it using mathcad, ret is always 0 no matter what in0 is before saving. Does it mean that the calculation result can not be saved? Is it possible to save the result through mathcad automation interface?

Thanks

Best answer by RichardJ

Posting your question and also sending a PM to someone has the same problem as double posting: you started two discussions that are unconnected, which wastes peoples time. The answer to your question is in this thread, which you found for yourself:

http://communities.ptc.com/message/173796#173796

As I just said in a PM: "As Werner pointed out, what is saved in the XML is not necessarily what appears in the worksheet next time it's loaded. You are looking at an evaluation, not an assignment. The results of the evaluation are saved in the XML so that (in theory) at some time in the distant future when Mathcad no longer exists the results of the calculation are still available in human readable form. However, when you open the Mathcad worksheet, since there is no assignment, there is nothing to evaluate. The only way to do what you want is to modify the XML of an assignment region.".

I just noted that in your sheet you do actually have an assignment ret:=in0. So there is something to evaluate, but since the default value for in0 is 0, that's what you get. You don't need that step, you could just use SetValue to set the value of ret directly, If you do that then when you open the sheet standalone ret will be flagged as an undefined variable. You can take your pick of those two, but what you cannot do is get ret to be 5 by using SetValue.

15 replies

1-Visitor
April 4, 2014

What version of Excel and Mathcad are you using?

Could you upload a worksheet?

1-Visitor
April 4, 2014

MathCad 15, Excel 2010.

I uploaded a excel file containing the mathcad object. If you have installed the add-in, I think you can save the object into a .xmcd file and check the result.

1-Visitor
April 4, 2014

I have the add-in for Excel 2007, but have never used it. The file opens but I do not know how to save the object into Mathcad.

1-Visitor
April 8, 2014

I create an example. I save the object into save.xmcd. When I open this file, it shows ret = 0. However, when I open this file with notepad, it shows

<ml:eval>
<ml:id xml:space="preserve">ret</ml:id>
<ml:result>
<ml:real>5</ml:real>
</ml:result>
</ml:eval>

5 is exactly the value I assign to in0 and ret(ret:=in0) through Excel. So I could not understand why it shows ret = 0 when opend by MathCad. Can anyone help with this?

Thanks.

Werner_E
25-Diamond I
April 8, 2014

When you save and reopen the Mathcad sheet, the sheet is stand alone and every connection to your Excel sheet is lost. So all ten input variables in0 to in9 default to 0.

When saving a sheet the last calculated results are saved and thats the reason you see the last value of in0 in the xml structure of your saved file when you open it with notepad. But as autocalculation is turned on the sheet is recalculated as soon as you open it at now the "new" values (0) for the input variables tale effect.

1-Visitor
April 9, 2014

Thank you! The saved value for in0 didn't recover when I turn off automatic calculation...It seems there's no way to save the sheet alone?

1-Visitor
April 14, 2014

@Werner @Richard

Thank you very much!