Some developers have noticed a change that we made in Visio 2007: more of the shapes we ship with Visio contain the GUARD ShapeSheet function. This was done to make some shapes work better with our new Themes feature and often just to take formatting more effectively in the first place. Here is an example of a networking shape colored red in Visio 2003 and in Visio 2007:
You can probably see why we thought that this was an important change to make. On the other hand, this newfound reliance on GUARD can cause problems for developers who expect that formula changes they make programmatically just work. With the new shapes (or any ShapeSheet cell containing a GUARD function), trying to set a guarded formula using FormulaU (note that we strongly recommend that you use FormulaU rather than Formula) will raise an exception. If the solution does not handle the exception properly (86db0528: “Cell is guarded.”) it can crash or end up in an inconsistent state.
There are several ways to deal with this issue. The first is to change your code to simply handle the exception and take no further action. This will mean that the behavior that you get will be what the shape designer intended.
Another way is to change your uses of FormulaU that might run into this problem to FormulaForceU. This will essentially ignore the GUARD in the cell and set the cell to the specified value. This is not ideal (since those GUARDs are there for a reason) but will get around any possible exceptions.
If you don’t have access to the source of the solution (or don’t want to have to deploy a new version) we have created a new registry key to change the behavior of all existing uses of FormulaU to FormulaForceU (or Formula to FormulaForce). The key to use is:
We don’t recommend this as a longer term solution, but it should work well for existing solutions that are hitting this problem.