• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • Visio blog on Orbus website
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network

Coding

Published on July 6, 2022 by David Parker

A Visio List Shape is also a Container

Structured diagrams have been around in Microsoft Visio since 2010 and I have always known that list shapes are a specialized container shape, however it still came as a surprise to me recently that a list shape can simultaneously act as a container shape!

There are a few examples of both container and list shapes in the Microsoft provided content in all versions of Visio desktop, and even in the subscription Visio for web. The most popular of these is the Cross-Functional Flowchart template which contains container shapes (the Swimlane and Separator shapes) within list shapes (Swimlane List and Phase List), which are within another container shape (CFF Container).

In Visio desktop, the Insert / Diagram Parts / Container allows you to choose from a number of pre-built container shapes. There is no button to insert a list shape, but you can create your own or easily modify one of the pre-built ones to behave as a list shape.

In this example, I just added a

I renamed the master as Belt List and ticked the Match master by name on drop option, then changed the User.msvStructureType to List from Container, and added the seven additional User-defined Cells rows as listed in the List Shape Details section in the Custom Containers, Lists and Callouts in Visio 2010 article.

Then I added visHeadingText, which is copied from the Swimlane shapes, with the formula:

=SHAPETEXT(Sheet.8!TheText)

This means that I will have access to the container text from any member shapes.

So now I have a list shape that will order member shapes from top to bottom… notice that the original Belt List shape has not yet realized that it has been made into a list… simply moving the old members will sort that out.

So far, this container will assume that everything dropped into it needs to become a list member, so now I want to make it more selective by adding in some more cells into the potential member shapes.

First, I added a special User-defined Cell, msvShapeCategories, to both the circle and rectangle shapes, with the value “Circle” and “Rectangle” respectively.

Next, I added three Shape Data rows, Container, ListPosition and Page to them with the following formulas, which are guarded to prevent editing in the UI:

  • Container
=GUARD(IFERROR(LISTSHEETREF()!User.VISHEADINGTEXT,IFERROR(CONTAINERSHEETREF(1)!User.VISHEADINGTEXT,"")))
  • ListPosition
=GUARD(LISTORDER())
  • PageName
=GUARD(PAGENAME())

I also inserted the Prop.ListPosition as the text, and dragged them onto the Document Stencil and named them as Circle and Rectangle.

So, if then insert these into the User.msvSDListRequiredCategories of the Belt List master shape, I will ony allow shapes with these categories to be inserted into the list.

I could add multiple instances of these shapes and they will inherit values from the list shape and page.

However, if I then remove Circle from User.msvSDListRequiredCategories and, instead, insert it into User.msvSDContainerRequiredCategories, then I will get different behavior.

The Circle shapes can be placed anywhere within the container, and they still recognize that they are within it, and will move with it. The Rectangle shapes still behave as list members.

Fortunately, the Visio API provides methods to get the shape ids of the list and container members separately. So, in VBA, the following sub will write out the names of the member shapes of the selected container shape:

Public Sub WriteMembers()
Dim shpContainer As Visio.Shape
Dim pag As Visio.Page
    Set shpContainer = ActiveWindow.Selection.PrimaryItem
    Set pag = ActivePage
Dim aryListMemberIDs() As Long
    aryListMemberIDs = shpContainer.ContainerProperties.GetListMembers()

Dim i As Integer
    Debug.Print "List Members of " & shpContainer.Name
    For i = 0 To UBound(aryListMemberIDs)
        Debug.Print , pag.Shapes.ItemFromID(aryListMemberIDs(i)).Name
    Next i
Dim aryContainerMemberIDs() As Long
    aryContainerMemberIDs = _
        shpContainer.ContainerProperties.GetMemberShapes( _
            Visio.VisContainerFlags.visContainerFlagsExcludeListMembers)
    Debug.Print "Container Members of " & shpContainer.Name
    For i = 0 To UBound(aryContainerMemberIDs)
        Debug.Print , pag.Shapes.ItemFromID(aryContainerMemberIDs(i)).Name
    Next i
End Sub

The output to the Immediate Window is:

List Members of Belt List.1011
              Rectangle.1019
              Rectangle.1017
Container Members of Belt List.1011
              Circle.1016
              Circle.1018
              Circle.1020
              Circle.1021
              Circle.1022

A similar count can be retrieved in the ShapeSheet, as in the following example where I inserted custom formulas into the text of two associated Callout shapes.

The callout on the left has the custom formula inserted:

="List Members="&CALLOUTTARGETREF()!LISTMEMBERCOUNT()

The callout on the right has the custom formula inserted:

="Container Members="&CALLOUTTARGETREF()!CONTAINERMEMBERCOUNT()

I will store this knowledge away for future use, but I thought I would share this in case others find it useful.

See https://docs.microsoft.com/office/client-developer/visio/listsheetref-function and https://docs.microsoft.com/office/client-developer/visio/containersheetref-function for ShapeSheet function information.

See https://docs.microsoft.com/office/vba/api/visio.containerproperties.getlistmembers and https://docs.microsoft.com/office/vba/api/visio.containerproperties.getmembershapes for Visio API information.

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…

Understanding Morse Clicks with Visio

A few years ago, I wrote an article about messaging and encryption inspired by a visit to the National Museum of Computing in the UK. I developed a Morse Click shape to demonstrate how Visio can be used to represent and learn Morse Code. However, I never published the shapes here, and my good friend…

Visio 2010 MVP Session videos reprise

Back in 2012, my fellow Visio MVPs, Scott Helmers and Chris Roth, and I recorded a series of 24 videos about Visio 2010. They were first hosted on Microsoft’s web site, then they put them up on YouTube, they they got deleted :-(. Well, we have managed to retrieve them, and put them back up…

Using Emojis in Visio

In the new normal of social distancing, we can easily miss the nuances of facial expressions with the the various electronic communication platforms that we utilise. In our personal communications via mobile apps, we have all started to use Emojis to express sentiment and actions, although we can sometimes convey the wrong meanings unintentionally as…

Using CODE() and UNICODE() functions in Visio

Microsoft Visio does have CHAR() and UNICHAR() ShapeSheet functions, just like Excel, but it does not have the inverse CODE() and UNICODE() functions, unlike Excel. However, there is a way to create a formula in the Visio ShapeSheet to provide these functions. The following worksheet demonstrates how the CHAR(), CODE(), UNICHAR(), and UNICODE() functions work…

Preventing Deletion of Container Members in Visio

The concept of Structured Diagrams was introduced in Visio 2010 and is featured in many of the templates supplied with Microsoft Visio, and in some third-party solutions, like mine. Connectors, callouts, containers and lists are the key parts of a structured diagrams, and there are times when preventing the deletion of members of a container…

Filed Under: Containers, Lists, Shape Design, Shape Reports, Uncategorized, VBA, Visio Tagged With: Containers, Lists, ShapeSheet Functions, Structured Diagrams, Visio

Published on June 4, 2021 by David Parker

Duplicating Visio Data Graphics

I was recently asked about switching between different Visio Data Graphics within a page, so I thought I should record a few short videos to explain how Visio Data Graphics work, how they can be edited and duplicated, and how to automate switching between them.

[Read more…] about Duplicating Visio Data Graphics

Filed Under: Data Graphics, VBA, Visio, Visio for Desktop Tagged With: Data Graphics, VBA, Visio

Published on June 2, 2021 by David Parker

Adding Macro Ribbon Buttons to Visio Documents from a Stencil

I wrote a post a few years ago entitled How to Run VBA Macros from a Ribbon Button in Visio 2010, and was recently asked how to add the custom buttons to an existing tab. Well, it got me thinking that I don’t really like having any VBA code in my Visio diagram documents, so I thought I would explain how all the code can be in a macro-enabled stencil so that it can be used with many different diagram documents. It turned out to be a very easy modification….

[Read more…] about Adding Macro Ribbon Buttons to Visio Documents from a Stencil

Filed Under: VBA, Visio, Visio for Desktop Tagged With: VBA, Visio

Published on March 5, 2021 by David Parker

Two Quote or Not Two Quote …

… that is the question!

I have known for some time that it is safer to copy and paste code from the web into Notepad or similar, before copying and pasting that into my own code. It is not only new line characters that can be different but also the double-quotes. I recently noticed this when I was writing my series on Visio ShapeSheet Functions A-Z because I make copious use of the EVALTEXT(…) function, so I investigated further and found that there are different double-quotes used when typing text into a Visio shape or typing into a Visio ShapeSheet cell!

  • Text fails to evaluate with smart double-quotes
  • Three versions of double-quote
  • Evaluating the CHAR(…) function
  • Text evaluates with straight double-quotes
[Read more…] about Two Quote or Not Two Quote …

Filed Under: Coding, ShapeSheet Formulas, Visio Tagged With: ShapeSheet Functions, Visio

Published on March 3, 2021 by David Parker

Viewing Visio Document Changes in Git

Developing a Visio solution usually involves both .Net code and Visio ShapeSheet formulas. Good practice dictates that the source code is saved into a code repository, such as Git, where changes can be committed and commented. Visual Studio 2019 now includes native Git support, and can be linked to Azure DevOps easily. The code can be viewed by others and the changes made by commits can be reviewed. This is tried and tested for the .Net code, but any changes made to a Visio template, stencil or drawing document is a black box. If the Visio document is included in the Git project, then all that is visible is the fact that the file has been changed, but the detail of the actual changes are unknown. There may be some comments with the commit, but that is not a precise definition. So, what if there was a way to easily spot the changes?

  • Make a small change to a Visio master
  • It registers as a change in Git
  • Cannot see what actually changed in DevOps
[Read more…] about Viewing Visio Document Changes in Git

Filed Under: C#, DevOps, Git, Shape Design, ShapeSheet Formulas, Visio, Visio for Desktop Tagged With: DevOps, DotNet Core, Git, ShapeSheet, Visio

Published on January 2, 2021 by David Parker

Referencing Visio Shapes

Every Visio shape must have a unique name in the collection that it belongs to, and to ensure this, Visio automatically one using the master name or just “Sheet”, if not an instance of a master, followed by a period (“.”) and the ID. However, a user can rename a shape, and Visio will then also update the universal name (NameU) to be the same as the Name. If a user chooses to re-name a shape a second time, then thee universal name is not updated … it remains as the original name.

To demonstrate this I drew a rectangle, then named, and re-named it:

  • Shape is automatically named
  • The Name and NameU are the same
  • The Name and NameU are initially the same
  • The Name U remains unchnaged when Name changed again
[Read more…] about Referencing Visio Shapes

Filed Under: ShapeSheet Formulas, VBA, Visio Tagged With: ShapeSheet, ShapeSheet Functions, Visio

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 9
  • Go to Next Page »

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • A Visio List Shape is also a Container
  • Taking Visio Actions Rows to the limit
  • TimeTable at RMConnect 2022
  • Custom Shapes in Visio in M365 and Web
  • A Multi-Time Zone Clock for Visio

Categories

Tags

Accessibility Add-Ins Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Themes Validation VBA Video Visio Visio 2007 Visio 2013 Visio for the Web Visio Online Visio Pro for Office365 Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • LinkedIn
  • Twitter

Search this website

Recent posts

  • A Visio List Shape is also a Container
  • Taking Visio Actions Rows to the limit
  • TimeTable at RMConnect 2022
  • Custom Shapes in Visio in M365 and Web
  • A Multi-Time Zone Clock for Visio

Copyright © 2022 · Executive Pro on Genesis Framework · WordPress · Log in