• 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
    • Visio Shape Report Converter
    • 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
    • Using Visio in Education for GIS
    • 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➡
      • Visualize Complex Processes with Microsoft Visio
      • 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
    • 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
You are here: Home / Visio / Visio 2010 / Visio 2010 : Containment and Cross-Functional Flowcharts

Published on September 7, 2009 by David Parker

Visio 2010 : Containment and Cross-Functional Flowcharts

One of the templates to get a revision in Visio 2010 is the Cross Functional Flowchart template because of the new list and containment functionality that has been added into the core application.  I had to write a small bit of code in earlier versions of Visio for each flowchart shape to automatically understand which swimlane and phase it belongs to, but now there are ShapeSheet functions available, so a slight modification of a flowchart master enables it to inherit values from the swimlane that it is in.  This article demonstrates who you can do this to, for example, synchronize the fill color of each flowchart shape to that of the swimlane that it belongs to.

image

The Cross Functional Flowchart template now includes its own add-in ribbon:

image

Each Swimlane shape is now a container shape, as is the CFF Container and Phase shapes.   Notice that the Process shape has a Shape Data row, named Function, which automatically updates itself with the text entered into the header text of the Swimlane that it is within.  Unfortunately, it is not the same for the Phase that it is within … perhaps Microsoft will correct this for the official release of Visio 2010, but in the meantime I will propose a workaround later in this post.  Additionally, the Function shape data row is displayed, regardless of whether it is within a Swimlane or not, therefore I will show how the visibility can be controlled to automatically hide if it is not within a Swimlane.

Container Categories

The new container masters have lots of new User-defined cells to define how they are to be handled, amongst which are the following two:

  • User.msvStructureType = ”Container”
  • User.msvShapeCategories = “Phase”

The second value will be CFF Container, CFF List, Swimlane or Phase, depending on which Master it is.

In the above example, the My Process shape is actually within three containers, a CFF Container, Swimlane and Phase (note that the new Phase shape actually extends from the Swimlane headers to the right hand line that has the Phase X label).

Listing the Containers that a Shape is Within

There are times when you will need to determine what containers a shape is within, and to be able to recognise what type of container it is.  The ListSelectedShapeContainers macro listed below will produce output in the Immediate Window like httis (if the My Process shape is selected first):

Process       My Process
ID            CFF Container CFF List      Swimlane      Phase         Name
20           False         False         False         True          Phase (vertical).20
4            False         True          False         False         Swimlane List
11           False         False         True          False         Swimlane.11

Public Sub ListSelectedShapeContainers()
Dim shp As Visio.Shape
If Visio.ActiveWindow.Selection.PrimaryItem Is Nothing Then
Exit Sub
Else
Set shp = Visio.ActiveWindow.Selection.PrimaryItem
End If

Dim aryContainerIDs() As Long
Dim containerID As Long
Dim iContainer As Integer
Dim containerShp As Visio.Shape

    Debug.Print shp.Name, shp.Text
aryContainerIDs = shp.MemberOfContainers()
Debug.Print , “ID”, “CFF Container”, “CFF List”, “Swimlane”, “Phase”, “Name”
For iContainer = 0 To UBound(aryContainerIDs)
Set containerShp = Visio.ActivePage.Shapes.ItemFromID(aryContainerIDs(iContainer))
Debug.Print , aryContainerIDs(iContainer), _
containerShp.HasCategory(“CFF Container”), _
containerShp.HasCategory(“CFF List”), _
containerShp.HasCategory(“Swimlane”), _
containerShp.HasCategory(“Phase”), _
containerShp.Name
Next iContainer
End Sub

Notice the new shape method MemberOfContainers() which returns an array of container shape IDs, which are then used to get the actual container shapes in order to discover what type of container they are using the new HasCategory() method.

Opening the ShapeSheet of the My Process shape reveals how the containing swimlane shape text is displayed in the Prop.Function row:

image

The new ShapeSheet function, CONTAINERSHEET() requires the index position in the list of container shapes, and the second argument enables the list of returned containers to be filtered by the category.  The Scratch.A1 cell formula is =User.visHeadingText, which has the formula =SHAPETEXT(Sheet.13!TheText) .

There is also a new function, CONTAINERCOUNT(), which returns the number of containers that the shapes is within.

Listing the Containers and Members on a Page

It is also possible to list containers on a page, and to list the shapes contained within them.  The following Immediate Window output was produced by the ListPageContainers() macro:

ID            CFF Container CFF List      Swimlane      Phase         Name
1            True          False         False         False         CFF Container
4            Swimlane List
6            Phase List
4            False         True          False         False         Swimlane List
8            Swimlane
11           Swimlane.11
17           Process
18           Process.18
6            False         True          False         False         Phase List
14           Phase (vertical)
20           Phase (vertical).20
8            False         False         True          False         Swimlane
18           Process.18
11           False         False         True          False         Swimlane.11
17           Process
14           False         False         False         True          Phase (vertical)
18           Process.18
20           False         False         False         True          Phase (vertical).20
17           Process

Notice that I did not filter out the contained containers, but I did filter out the connectors (1D) shapes.

Public Sub ListPageContainers()
Dim aryContainerIDs() As Long
aryContainerIDs = Visio.ActivePage.GetContainers(visContainerIncludeNested)
Dim containerID As Long
Dim iContainer As Integer
Dim containerShp As Visio.Shape

Dim aryMemberIDs() As Long
Dim memberID As Long
Dim iMember As Integer
Dim memberShp As Visio.Shape

    Debug.Print “ID”, “CFF Container”, “CFF List”, “Swimlane”, “Phase”, “Name”
For iContainer = 0 To UBound(aryContainerIDs)
Set containerShp = Visio.ActivePage.Shapes.ItemFromID(aryContainerIDs(iContainer))
Debug.Print aryContainerIDs(iContainer), _
containerShp.HasCategory(“CFF Container”), _
containerShp.HasCategory(“CFF List”), _
containerShp.HasCategory(“Swimlane”), _
containerShp.HasCategory(“Phase”), _
containerShp.Name
aryMemberIDs = containerShp.ContainerProperties.GetMemberShapes(Visio.VisContainerFlags.visContainerFlagsDefault)
For iMember = 0 To UBound(aryMemberIDs)
Set memberShp = Visio.ActivePage.Shapes.ItemFromID(aryMemberIDs(iMember))
If memberShp.OneD = False Then
Debug.Print , aryMemberIDs(iMember), memberShp.Name
End If
Next iMember
Next iContainer
End Sub

Notice the new page method GetContainers() which returns an array of container shape IDs.  These container shape IDs are then used to retrieve the actual shapes, and the new shape collection ContainerProperties has a method GetMemberShapes() which will retrieve the desired member shapes.

There is also a new ShapeSheet function, =CONTAINERMEMBERCOUNT(), which returns the number of shapes contained within it.

Displaying the Header Text

As stated earlier, the Swimlane master has a user-defined cell, visHeadingText, which contains a reference to the text of a sub-shape (Sheet.7 in the Master).  However, the Phase master does not, therefore I added the visHeadingText user-defined cell to the Phase master in the local stencil, with the same formula, because the text edit target shape in that master is also Sheet.7.

User.visHeadingText = SHAPETEXT(Sheet.7!TheText)

This means that you can then edit the flowchart masters, for example the Process master, to display the enclosing Phase shape in a new Shape Data row, in the same manner as the Function Shape Data row.

imageLike before, these edits were done to the master on the local document stencil.

A useful consequence of having the Phase in each shape is that these values will now be exposed to the Visio reporting tool.

Controlling Visibility of the Shape Data Rows

To avoid the needless display of Shape Data rows when they are not relevant, I decided to add formlae to the Function and Phase Shape Data rows.

image

Note that the values display #REF! in the master ShapeSheet, which makes it reasonable to assume that we can use the ISERROR() function to determine whether or not there is an enclosing swimlane:

Prop.Function.Invisible = ISERROR(CONTAINERSHEETREF(1,”Swimlane”)!NAME())

A similar formula was added to Prop.Phase.Invisible: = ISERROR(CONTAINERSHEETREF(1,”Phase”)!NAME())

Synchronizing the Flowchart Shape Fill Color with the Swimlane

Finally, I get to set the fill format ell values so that the Process master is synchronized with the enclosing swimlane.

image

The Fill Format section of the Process master has several modified formulae in order to synchronize the fill color wit the enclosing swimlane.  Fortunately, I have already setup a cell which tells me if the shape is inside a swimlane or not, so it is a simple matter to refer to that value to evaluate whether to apply the fill properties of the enclosing swimlane, or just to use the default values from a theme.

image

So, there we go, we can now enhance the Cross Functional Flowchart template with just ShapeSheet functions … the new containment features of Visio 2010 are really useful additions to the rich developer interface … enjoy!

Related

Filed Under: Containers, Lists, Process Flows, VBA, Visio 2010

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Comments

  1. Marko says

    July 18, 2012 at 8:53 pm

    Hi, I’m looking for a way to extract info about container and childs from a VDX file…do you maybe know how I can do this?

    Reply
    • davidjpp says

      July 19, 2012 at 12:47 pm

      I think you should check:
      VisioDocument\Pages\Page\Shapes\Shape\v14:Relationships\F

      Here is a an example formula in one that has a container relationship:
      F=”SUM(DEPENDSON(4,Container 7!SheetRef()))”

      Check out http://msdn.microsoft.com/en-us/library/ff768326.aspx

      Reply
  2. Christian Jung says

    January 10, 2013 at 12:33 am

    Hi David,

    I’m a visio newbie. May be my question is a bit ridiculous…

    By placing a shape on a swimlane the function property is automatically set to

    IFERROR(CONTAINERSHEETREF(1,”Swimlane”)!User.VISHEADINGTEXT,””)

    That’s fine because when I move the shape around the property will be set accordingly.

    Now I want to extract the function property programatically (in the UI I see the result of the formula) and write it to somewhere else. But how can get to the result of this formula without evaluating it myself (i.e. searching for the swimlane shape and acessing the heading text)? I tried the formula and formula property of the corresponding cell which will yield the above formula and not the result of the evaluation…

    Thanks,
    Christian

    Reply
    • Christian Jung says

      January 10, 2013 at 10:09 am

      Nevermind. Solved it myself 🙂 It’s as easy as

      cell.ResultStr(visUnitsString)

      Sorry for the dumb question.

      Reply
  3. JaxJoe says

    December 18, 2013 at 5:35 pm

    Am using Visio 2013 as BPMN tool (v2.0). Have 2 pools…1 of which has multiple lanes. This is what I can’t figure out: Some of the BPMN task dragged into the lane has the prop.Function attribute set to the lane’s Name. However, other tasks I drag into a lane, don’t even show the prop.Funtion attribute on the Shapesheet. When doing the same mechanics (as far as I know), what is causing some BPMN tasks to show this on the Shapesheet and others not?

    Thanks in advance for any…all help.

    Reply
    • JaxJoe says

      December 19, 2013 at 1:49 pm

      I discovered a couple tidbits but not how to prevent the problem nor how to fix the diagram that I already have. In terms of the discovery:

      1. If I add a new lane to the existing pool then, drag-drop a BMPN Task, the Prop.Function is set to the Lane properly. (This same operation did not populate Prop.Function until the new lane was added.)
      2. Going to the Edit>Undo list, the action of adding a new Lane was/is called “Insert into List”. Somehow, this “Insert into List” Visio function somehow fixed the assignment of Prop.Function to all new BPMN Task drag-drop’s.
      3 Completing the Edit>Undo of the “Insert into List”, a drag-drop of the BPMN Task leaves me w/o the Prop.Function property and associated Lane assignment.

      2 Questions:
      1. Somehow, my existing BPMN diagram seems somehow “out of sync” with normal/expected Visio behavior. How can I fix this short of recreating everything as its a very big, complex diagram. In other words, is there a way to force Visio to reconstruct, clean-up, fix the diagram?
      2. Is there a way, via VBA, to loop through all of the objects on the diagram, which should have Prop.Function set to the Lane, and set it programmatically as a workaround (I don’t know how to do this. If possible, I would really appreciate your help.)

      Thanks again.

      Reply
      • davidjpp says

        January 27, 2014 at 9:24 am

        The assignment of the value in Prop.Function is done by the formula
        =IFERROR(CONTAINERSHEETREF(1,”Swimlane”)!User.VISHEADINGTEXT,””)
        Note that the cell contents are not guarded, so they could be accidently overtyped in the UI (or in code).
        The flow chart shapes have this formula in their master, so you can loop through all shapes that have the Prop.Function cell that is inherited, and enter the formula “=” (that is a shortcut to re-inherit from the master)
        The CFF addon can apply this formula to any shape that is dropped inside a Swimlane, so you may just want to test for the existence of Prop.Function and apply the whole formula:

        Public Function FixFunction()
        Dim shp As Visio.Shape
        For Each shp In Visio.ActivePage.Shapes
        If shp.CellExists(“Prop.Function”, Visio.visExistsAnywhere) 0 Then
        shp.Cells(“Prop.Function”).FormulaU = _
        “=IFERROR(CONTAINERSHEETREF(1,””Swimlane””)!User.VISHEADINGTEXT,””””)”
        End If
        Next
        End Function

        Next

        Reply
    • davidjpp says

      January 27, 2014 at 9:34 am

      Looking at the BPMN masters, I personally think that it was an error of judgement by Microsoft not to include the Prop.Function Shape Data row by default, because letting the CFF addon create that row on the fly, whenever you drop a shape into a Lane, means that the whole Shape Data section becomes local, rather than inherited. Given the large number of rows in the Shape Data section of the BPMN masters, then it will have an effect on file size.
      You can amend the code in my other answer to you to add Prop.Function rows where needed.

      Reply
      • JaxJoe says

        January 27, 2014 at 11:48 am

        While I haven’t completed digested your feedback, I did want to take a quick minute to say “thanks”.

        Reply

Trackbacks

  1. Writing rules to validate diagrams in Visio 2010 – A worked example | bVisual - for people interested in Microsoft Visio says:
    December 31, 2018 at 9:17 am

    […] Visio 2010 : Containment and Cross-Functional Flowcharts […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript LayerManager Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Setup and Deployment Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Validation VBA Video Visio Visio 2007 Visio for the Web Visio Online 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

  • Amazon
  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Search this website

Recent posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

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