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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Unable to save the Worksheet using automation API

nileshwankhade
1-Visitor

Unable to save the Worksheet using automation API

Hi All,
I am using JACOB to alter the input values of the mathcad worksheet and to generate the output dynamically using Mathcad automation API
I am able to do this successfully.
When I observed the worksheet, the generated output values are visible but the values which I set programmatically are not visible.
I try to save the file and reopen it but this time I lost output values as well.

Please let me know if there are any settings I need to modify.

Note: I tried the same thing with VB script as well but it is of no use.


Thanks and Regards,
Nilesh
3 REPLIES 3

make sure you have made visible the API's active worksheet, rather than having accidentally opened a copy of the same worksheet.
I have had that problem in the past. What I saw on screen was not the sheet that the API was accessing !!


Philip Oakley

On 10/8/2009 4:12:24 AM, philipoakley wrote:
>make sure you have made
>visible the API's active
>worksheet, rather than having
>accidentally opened a copy of
>the same worksheet.
>I have had that problem in the
>past. What I saw on screen was
>not the sheet that the API was
>accessing !!
>
>
>Philip Oakley


I made the worksheet visible in the Jacob and VB script as well.

Please find the attached worksheets get the overview of the problem i am facing.
01. Original worksheet in which inputA = 10, intpuB and outputC=inputA+intpuB
02. Programmatically i am setting the value of inputB=15 in worksheet
Now after calling "Recalculate" i am able to see the value of outputC=25,
But value of inputB is not visible.
03 I tried to save the visible worksheet, manually as well as programmatically
But when i reopened the worksheet, values of inputB and outputC are not visible.

I also compared the xmcd files, (original and programmatically saved worksheet)
the generated outputC value is present in worksheet (I mean the "eval" tag of xmcd file)


Please suggest


Regards
Nilesh


On 10/8/2009 4:45:13 AM, nileshwankhade wrote:

>Please find the attached worksheets get
>the overview of the problem i am facing.
>01. Original worksheet in which inputA =
>10, intpuB and outputC=inputA+intpuB

I think you posted the wrong worksheet.

>02. Programmatically i am setting the
>value of inputB=15 in worksheet

I assume you are doing this using SetValue, rather than modifying the XML of the worksheet?

>Now after calling "Recalculate" i am
>able to see the value of outputC=25,
>But value of inputB is not visible.

You misunderstand what SetValue does. When you call SetValue to set the value of InputB it binds the variable prior to anything on the worksheet, and assigns it a value. Any subsequent assignment (which means any assignment on the worksheet) to the same variable name will overwrite that assignment. The binding exists only as long as the worksheet object you created (which is not the worksheet itself) exists. That is true even if you save the worksheet, because there is no assignment statement created in the worksheet, just a variable binding. When you exit the script the worksheet object is destroyed, and the variable binding with it. Your assignment of InputB to an empty placeholder is ignored, just as it would be if you simply typed InputB:22 at the top of the worksheet, and outputC is calculated and displayed. If you want to see the value of inputB you need an evaluation statement, not an assignment.

>03 I tried to save the visible
>worksheet, manually as well as
>programmatically
>But when i reopened the worksheet,
>values of inputB and outputC are not
>visible.

Because you have not created a variable assignment in the worksheet. That is possible, but you need to modify the XML of the worksheet to do it. Stuart has posted an example somewhere.

Why are you trying to do this? I don't see the point in having multiple copies of a worksheet that differ only in the assigned values of one or more variables. The whole point of Mathcad is that it is not some static document like a pdf, and if you change the values assigned to variables the worksheet recalculates. If you want to limit the assigned values to only certain choices, why not just use a listbox?

Richard
Announcements

Top Tags