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