Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: Visisthebest on November 25, 2022, 11:01:29 AM

Title: Visio List Shape - how to guard PinX and PinY formulas when item added to list?
Post by: Visisthebest on November 25, 2022, 11:01:29 AM
I have become quite fond of the Visio List Shape functionality, as described here:
https://bvisual.net/2022/07/06/a-visio-list-shape-is-also-a-container/

(rarely I use a Container/List combo, mostly just a List)

The problem I encounter is that for a solution I need formulas in the List shape for PinX and PinY. However, when a list item (shape) is added to the List shape, PinX and PinY are overwritten with a value and the formula is lost. GUARD()-ing the PinX and PinY formulas doesn't help, the formulas still get erased.

Is there another way to protect the PinX and PinY formulas from this behavior of the list shape when an item is added? Thank you for sharing your ideas for a solution!
Title: Re: Visio List Shape - how to guard PinX and PinY formulas when item added to list?
Post by: Yacine on November 25, 2022, 01:57:37 PM
Yes, the setatref group of functions should help.
Wapperdude has written a nice post about them.
Title: Re: Visio List Shape - how to guard PinX and PinY formulas when item added to list?
Post by: Visisthebest on November 25, 2022, 02:15:28 PM
Thank you Yacine checked out the MS info on SETATREF():
https://learn.microsoft.com/en-us/office/client-developer/visio/setatref-function

That should work will read up on it from Wapperdude's article as well thank you!
Title: Re: Visio List Shape - how to guard PinX and PinY formulas when item added to list?
Post by: Visisthebest on November 25, 2022, 02:16:49 PM
By the way, is there also a DEPENDSON() that fires when a formula changes (not just the resulting value)? That would be pretty useful in some cases.
Title: Re: Visio List Shape - how to guard PinX and PinY formulas when item added to list?
Post by: wapperdude on November 25, 2022, 08:10:40 PM
My guess is maybe.  Dependson()  is based upon a change in the reference cell.  Presumably, that means the cells value.  But what if  setf() or vba places a new formula?  I'm not sure.  Try a simple test case.  Say set a shape"s width to some value only when color changes.  This allows you to enter a color from GUI, or edit shape sheet to use setf() to enter an RGB  value, or use code to place a formula.
Title: Re: Visio List Shape - how to guard PinX and PinY formulas when item added to list?
Post by: Visisthebest on November 26, 2022, 12:23:57 PM
Wapperdude thank you again for your comprehensive articles on the SETATREF functions!

It is some SETATREF(SETATREFEVAL(SETREFEXPR())) formula construction magic that completely solved this problem. Superuseful!
Title: Re: Visio List Shape - how to guard PinX and PinY formulas when item added to list?
Post by: celoranta on September 20, 2023, 03:59:03 AM
Can anyone share what worked?
My SETATREF() formulas in list fields are being overwritten, and I'm not sure how you guys resolved it...
Title: Re: Visio List Shape - how to guard PinX and PinY formulas when item added to list?
Post by: Visisthebest on September 20, 2023, 08:27:39 AM
celoranta I think this only works for the list container itself (to move the list container with another shape), the list field shapes (the container list members in Visio-speak) probably have built-in behavior that determines their position that may override everything else even SETATREF() formulas.

What are you trying to achieve?