Site icon bVisual

Referencing Container Data in Visio

Microsoft Visio has a useful Structured Diagramming concept that consists of Containers, Callouts and Connectors. The first of these features make it possible for shapes to know what they are contained within, as a better option to grouping shapes together. Grouping can hide or break the grouped shapes smartness, so Visio provides two ways of allowing shapes to be members of one or more containers. There are a few built-in Container shapes that can be added with the Insert / Diagram Parts / Container gallery, but shape developers can also create their own. Member shapes can be positioned anywhere within the container. There is a second type of container, List, that provides the ability to have ordered member items. There is no ribbon command to add these, but there are a number of these special shapes provided in the OOTB Visio stencils. For example, dragging and dropping a List box shape from the Software and Database / Software / Controls stencil will automatically add three List box item shapes to it.

There is a dedicated ribbon tab, Container Format, that appears when you select a container shape, which provides some extra commands, but I want to demonstrate how a member shape can reference data in its container shape in the ShapeSheet. I edited the Belt and List box masters in the Document Stencil above by adding a Title Shape Data row. Of course, I also ticked the Master Properties / Behavior / Match master by name on drop option to prevent Visio creating duplicate masters. I also ticked this for List box item master because I want to edit that too.

First, I simply added a Shape Data row to each master, but made them read-only so that they displayed the text in the heading shape of each.

The Belt master’s heading shape is Sheet.8, so the Prop.Title.Value cell formula is:

=GUARD(SHAPETEXT(Sheet.8!TheText))

The List box master’s heading shape is Sheet.6, so the Prop.Title.Value cell formula is:

=GUARD(SHAPETEXT(Sheet.6!TheText))

Next, I edited the text of the List box item master by using Insert / Field:

The following formula will either display the position of the item within its List container, or it will display that it is #0 of no list.

="#"&LISTORDER()&" of "&IFERROR(LISTSHEETREF()!Prop.Title,"no list")

The LISTORDER() function will return the position in the list, and LISTSHEETREF() function gets a reference to it. The ISERROR(…) function provides the fallback value if the specified cell does not exist in the referenced list container, or if there is no list container at all. The list container could also make use of the LISTMEMBERCOUNT() function if you wanted to display that.

The rectangle shape text was also edited to display the Title Shape Data of its container.

This is the simplest form of the CONTAINERSHEETREF(…) function, because it simply references the first container it is within:

"I am in "&CONTAINERSHEETREF(1)!Prop.TITLE

Of course, the CONTAINERSHEETREF(…) expression could also be enclosed within an IFERROR(…) function, to handle the case where there is no container. In addition, the CONTAINERSHEETREF(…) function has an optional second argument to filter the collection by a named shape category. There is also a CONTAINERCOUNT() function to get the total number of containers that a shape is within, and a CONTAINERMEMBERCONT() function for a container to get the number of members that it has.

Note that I had to re-drop a List box item shapes to use the new text formulas automatically.

These functions are also used extensively in Cross-Functional Flowchart diagrams, where multiple container shapes (swim-lanes) are found within a list shape. All of this functionality works in Visio for Web, so there is no excuse on making smart shapes for everyone!

Synchronizing Visio Shape Fill Color (or almost any cell) across pages

I was recently asked how the color of one shape can be changed and for other shapes to be automatically updated to the same color … even if they are on different pages! Well, it is possible with Microsoft Visio’s awesome ShapeSheet formulas. In fact, this capability is not limited to the FillForegnd cell ……

Positioning Visio Shape Text Block with a Control Handle

I was recently asked how a control handle can be added to a Visio shape so that it can be used to re-position the text block. Fortunately, it is extremely easy to setup, and requires just two formulas to be updated in the ShapeSheet. This is a great use of the SETATREF(…) function. (more…)

Understanding Segments of Visio Geometry

I recently had to revise my understanding of the POINTALONGPATH(…) function in Visio because I was getting a #REF! error in some cases. My particular scenario requires a line with a number of vertices that are initially all in a straight line but can be moved by dragging controls around that each vertex is bound…

Custom Color Themes in Visio?

I was recently looking into custom color themes for corporate branding in desktop Microsoft Visio and became re-aware how different Visio still is from the rest of the Microsoft Office applications. A Visio page or document does not need to have any theme applied, but the documents of the other Office applications always have a…

When is a Visio Callout not a Callout?

I have been a Visio user/developer since the mid-1990’s and seen the word “callout” used as part of the name of many master shapes in Visio. The images below show five ways that the term “callout” has been applied to the name of Visio master shapes. Generally, each evolution has been an advance on the…

Using Visio Color by Value on Connectors

Data Graphics in Visio Plan 2 and Visio Professional is great, but it only enables us to use them with 2D shapes in Visio, i.e. not on connectors. So, what if you want to change the line colour of the connectors between the 2D shapes because of the data flowing between them? Well, it is…

Exit mobile version