Part of formula replaced by value

G

Gary Shell

I am executing this line of code:

shpObj.Cells("piny").Formula = "GUARD(" & strTheLane & "!User.RY-" &
strTheLane & "!Height/ 2)"

But what I see in the Shapesheet of the object in question is:

=Functional band.19!User.RY-2 in

I was hoping to get:

=Functional band.19!User.RY- Functional band.19!Height/2

First, where did my GUARD go? Second why does the first part (referencing
USER.RY) stay as a formula, but the second part get turned into a value? I
am trying to center a shape in a swimlane (Functional Band.19) so that when
the lane is resized the shape stays in the center.

Gary Shell
 
M

Mark Nelson [MS]

Make sure that your formula starts with an equals sign:

Formula = "=GUARD(" ...
 
G

Gary Shell

It does. That was a typo when I transcribed the code to the message. So my
problem still exists. The GUARD is stripped off and I get a constant in the
second half of the formula where I was expecting a variable.

Gary
 
M

Mark Nelson [MS]

I don't see a problem with the expression. A basic check would be to build
up the entire formula string separately before assigning it to the cell.

I do want to point out that your code will only work once. After a GUARD
has been placed in a cell, you cannot use the Formula method to set a new
formula. Visio should throw an error at that point. You need to use the
FormulaForce method to set a formula that will override an existing GUARDed
formula.

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Gary Shell

Thanks for the tip on the FormulaForce, but I am only doing this once for
each shape.

As a "basic check" I ran this and set a breakpoint on the line.

shpObj.Cells("piny").Formula = "GUARD(" & strTheLane & "!User.RY-" &
strTheLane & "!Height/ 2)"

I looked at the evaluation of the expression and saw : "=GUARD(Functional
band.19!User.RY- Functional band.19!Height/2)"
as expected. Yet when I go to the shapesheet I see: =Functional
band.19!User.RY-2 in.

There is no sign of a GUARD at all. And the portion of the formula after the
minus sign has been evaluated and replaced by the value "2 in.", which is
the correct value, if I wanted a value. <grin>

Again, I fear I may be fighting the Cross Functional FlowChart Template.

Thanks,
Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top