Dropping and Connecting Linked Data Shapes in Visio

I like linking data to shapes in Visio. It saves time in filling in Shape Data and adding text, or any Data Graphic to them. Basically I am lazy, and I also like to create macros for repetitive tasks, so in this blog I provide two macros to save the drudgery of two tasks I do so often:

  1. Dropping and data linking a number of items from an External Data recordset filtered by values in a column or columns
  2. Connecting shapes together following a parent-child relationship between Shape Data values

 

I have provided these two macros in the DataRecordset Utils.vssm file which can be downloaded from at http://1drv.ms/1KPISVG, and as usual, I recommend putting the file into you My Shapes folder so that it can be opened easily, just like any stencil.

Dropping and data linking shapes filtered by column values

First of all, I use the OrgData.xls file (with two extra columns) that auto-generate hyperlinks provided with Visio as an example data source.

Secondly, I just dragged an dropped one row onto the page because this auto-creates a master called Rectangle.

Thirdly, I created some Data Graphics for this Shape Data, then deleted the shape.

These steps are only necessary for my example, but you could have your own External Data, master and Data Graphics.

image

By the way, I can see the name of a Data Graphic in the tooltip of a Data Graphic icon in the DATA \ Data Graphic dropdown gallery, or I could change its name with the right mouse menu.

image

The macro-enabled stencil appears as Drs Utils in when opened, and does not contain any shapes.

So, the first macro, DropFiltered, can be run when a master is selected in a stencil, and a row is selected in the External Data window.

image

This macro will open a dialog in which I can select the column, or columns, that contain the values in the selected row that I wish to filter by.

It also allows me to optionally select a Data Graphic to be applied to each shape when it is dropped in the page.

image

The second column displays the data type where 0 is text and 2 is number.

When I press Select, the matching rows are used to drop an array of the selected master shapes, each one linked to each data row.

image

This saves time on selecting individual rows.

Connecting shapes together following a parent-child relationship between Shape Data values

In noticed that the Marketing team reported to managers and directors that are not in the same Department, so I just found those three rows and dropped them into the page.

image

The next macro, ConnectFiltered, simply requires the Primary Key column, or columns, in the active External Data recordset to be specified, along with the column, or columns, that contains the values for the Parent Key. It also allows for optionally linking the connector shape to the data recordset row, and for applying a Data Graphic.

UPDATE : I have added the ability to optionally delete any existing connections on each shape – I found myself having to delete too often!

image

Then, when I click Select, the data values are followed to used to connect the data linked shapes on the page together using the Dynamic connector master shape.

image

I then used the DESIGN / Layout / Re-Layout Page gallery to choose a suitable style.

image

Alternatively, I could have selected a connector type (1D) shape in a stencil in order to use a specific master.

image

This give me flexibility to choose the appropriate style.

image

I hope this helps some users to create data-driven diagrams quicker, and replaces some of the functionality that Microsoft deprecated years ago when they cut-out the Flowchart and Network Diagram wizards….

Downloads

Visio 2013 and later : http://1drv.ms/1KPISVG

Visio 2010 and earlier : http://1drv.ms/1QwH0WK

This stencil provides more generalised code for the action in a previous article : https://blog.bvisual.net/2009/02/24/creating-an-org-chart-without-the-org-chart-wizard/

6 Responses to “Dropping and Connecting Linked Data Shapes in Visio”

  1. Louise Chapman Says:

    “I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.” – Bill Gates.

  2. adumont Says:

    Hi David,

    I have shapes on my Visio page linked from two External Data Set: some shapes are linked to set People, and other to set called Offices. One of the data field (office) of shapes “People” refer to name of a shape in set “Offices”, and I’d like to connect the People shapes to their respective Office shape using Visio connectors. I thought I could do it with this example, but if I understand correctly, this example here works with a single Data set, not two.
    Do you think it would be possible to do such thing?

    • davidjpp Says:

      Certainly it is possible. Simply loop thru the personnel recordset, retrieve the linked shape and office key. Then use the office key to filter the office recordset, and get the linked shape. You can then connect one to the other.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

davecra.wordpress.com/

Microsoft Office Development, and more...

PowerShell.Amsterdam

Automate, Accelerate, Accurate

johnvisiomvp

Life with Visio and other Microsoft Toys!

Title (Required)

Windows Server Essentials Tips & Tricks

Nilsandrey's Weblog

Just another WordPress.com weblog

Things that Should be Easy

Every so often (too often in the IT industry) I encounter things that should have been very easy to do but turned out to be far too complicated. My favorite topics include SharePoint, .Net development, and software architecture, especially distributed systems.

Visio Guy

Shapes, Stencils, Drawings Templates, Tutorials, Tips & Developer Info for Microsoft Visio

Hannes's Virtual Earth

Tips & Tricks around Mapping and Cloud Computing

Pluralsight blog

be smart, be clear, be visual ...

%d bloggers like this: