Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: red on November 18, 2008, 05:07:35 PM

Title: Turn Layers on and off
Post by: red on November 18, 2008, 05:07:35 PM
I'm using Visio 2003. I'm working through the Sept 5, 2006 Visio Guy post the "The Hidden World of Shapes". I set up a shape on my main layer that allows me to right click and toggle the value of a user variable (User.Color) between 0 and 1. In one implementation, I use the following in the NoShow area of other shapes to toggle the shape on/off

=IF(Callout 1!User.Color=0,1,0)

This works great to toggle the individual shape on/off.

Now, I wanted to do the same thing, but to turn an entire layer on/off.

I thought I followed the example, but when I enter the formula above in the Visible cell of the Layers on the Page Shape Sheet, I get a formula error message. It is the exact same formula that I successfully use at the shape level since I copy and paste. I tried adding a Pages[Page-1]! reference but got the same error and also referring to is as ThePage!User.Color with the same result.

My guess is that there is something special I need to do to reference a shape user cell from the page shape sheet, but I'm at a loss at what to try next. The shape I'm selecting is not on the layer I'm turning on/off.

Any thoughts?

Title: Re: Turn Layers on and off
Post by: Visio Guy on November 19, 2008, 06:34:35 AM
Hi Red,

Check out the "Layers" section in this article: The Hidden World of Visio Shapes (http://www.visguy.com/2006/09/05/the-hidden-world-of-visio-shapes/)
Title: Re: Turn Layers on and off
Post by: red on November 20, 2008, 10:18:58 AM
I thought I was following the article, however upon rereading it appears that Layers are another example of things that need to use SETF, rather than allowing me to put a formula in the Layers.Visible cell that references a value n another cell. I've now run across this twice, and it is not very clear to me what the criteria are for when I can use a formula in a cell and when I have to use SETF. Any good references for this?

At any rate, I've now made it work for a single layer using the method in the article, but what I really need to do is simultanously toggle two layers by turning one layer off and another on at the same time. How do I structure the action formula to accomplish two things? Is there a way to execute two of the SETF formulas in the action with some sort of delimiter or something?
Title: Re: Turn Layers on and off
Post by: michelleh on November 20, 2008, 09:53:38 PM
Just put a "+" in between the function calls:  SETF(...) + SETF(...)
Title: Re: Turn Layers on and off
Post by: red on November 24, 2008, 10:11:22 AM
Great, that works.

So the only mystery left is why I can't reference a cell value from another shape in the pages shape sheet, as opposed to using SETF from the shape to set the value in the page cell. I have no problems within the page shape sheet referencing cells within the page shape sheet. For example, I use SETF to fix the value of visible in the layers, and then write a formula to make the print value match the visible value.

What I'm doing works, I'm just not sure I understand why it doesn't work with direct cell references.
Title: Re: Turn Layers on and off
Post by: Visio Guy on November 24, 2008, 04:59:16 PM
Here's a related example that works without using SETF.

See what happens when you flick the switch!