Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: siric on April 19, 2012, 09:07:51 PM

Title: [SOLVED] Change line color depending on value in ShapeSheet
Post by: siric on April 19, 2012, 09:07:51 PM
Hello,


I have a value in my shapesheet which defines the capacity of a data link - 1 (Red), 10 (Blue), 155 (Green) etc.  What I want to do is to change the color of the line depending on the value.  The shape property is Prop._VisDM_Capacity, so I am using this formula, but the line stays black

="IF(Prop._VisDM_Capacity=1,THEMEGUARD(RGB(255,0,0)), IF(Prop._VisDM_Capacity=10,THEMEGUARD(RGB(51,102,255)), IF(Prop._VisDM_Capacity=155,THEMEGUARD(RGB(51,153,102)))))"

I have also tried it as

="IF(Prop._VisDM_Capacity=1,RGB(255,0,0), IF(Prop._VisDM_Capacity=10, RGB(51,102,255), IF(Prop._VisDM_Capacity=155,RGB(51,153,102))))"

but no difference.

Any assistance would be appreciated.


Thanks





Title: Re: Change line color depending on value in ShapeSheet
Post by: JohnGoldsmith on April 20, 2012, 07:50:03 AM
Hi,

You're just missing the final part of your IF statement.  I find the 'Edit formula' dialog useful for longer formulae as you can add line breaks and whitespace, which are then ignored as you accept the formula back again.  For example if you break up your first formula (see attached image) it becomes easier to see where the problem is (missing final false part).

If you just add a zero (black) as your final 'false' parameter then this will be the default value if none of the other conditions are met:

=IF(Prop._VisDM_Capacity=1,THEMEGUARD(RGB(255,0,0)),IF(Prop._VisDM_Capacity=10,THEMEGUARD(RGB(51,102,255)),IF(Prop._VisDM_Capacity=155,THEMEGUARD(RGB(51,153,102)),0)))

Best regards

John
Title: Re: Change line color depending on value in ShapeSheet
Post by: siric on April 20, 2012, 01:29:13 PM
Thanks Very much!! :)
Title: Re: [SOLVED] Change line color depending on value in ShapeSheet
Post by: dasadler on May 11, 2012, 10:17:29 PM
A follow on question if I may. I know this dealt with a line (connector) but I expect the same principle would apply to a shape.  I wonder, though, how would you do it if the value in question was text?



Title: Re: [SOLVED] Change line color depending on value in ShapeSheet
Post by: JohnGoldsmith on May 12, 2012, 09:06:57 AM
If you mean how could I set the text color, then you can just use a similar formula in the Color cell of the Character ShapeSheet section. 

If you mean how can I change shape text based on some other logic, then you can use an inserted field (see the Insert tab on the ribbon).  If you have a specific scenario, why not flesh out the details in a new thread and we can solve it there.

All the best

John
Title: Re: [SOLVED] Change line color depending on value in ShapeSheet
Post by: Jumpy on May 15, 2012, 07:56:04 AM
And if you mean, how to change the color depending on a textvalue, not a number value, you have to use the STRSAME-Function, so instead of:

=IF(Prop._VisDM_Capacity=1,THEMEGUARD(RGB(255,0,0)).....

=IF(STRSAME(Prop._VisDM_Capacity,"Text_123"),THEMEGUARD(RGB(255,0,0))....

hth Jumpy