Visio Data Modelling and VBA

I use Visio for a number of tasks. For creating geodatabase models in ArcGIS, for system architecture diagrams, and for data flow models. It may not be the easiest program to use, but the alternatives are often too simplistic, or worse.

I wanted to generate a nice diagram of a SQL Server database I had created, and automatically create hyperlinks that would pop up an Ajax box with sample records directly from the database. In order to do this each hyperlink had to have a variable based on the table/entity name. However it soon became apparent that there is no easy way to access the entity name in VBA from its associated shape object. The solution to this is the VisioModelingEngine library which provides access to the UML, but does not provide access to the shapes.

There appears to be very little documentation on using the classes in this library. I found a couple of examples at and

My eventual workaround involves temporarily changing the first attribute in an entity to the entity name, searching through the shape’s text for this name, recording the ID and then changing it back. The idea was based on this post which hinted that was what they did, but then frustratingly didn’t post their solution.

Anyway the main use of the code is to associate a Visio entity (IVMEEntity) with its shape.

The full VBA code can be seen by clicking this link.

A good source of VBA scripts for Visio can be found at this provided me with the code for looping through shapes on a page.

Discussion has just started! Join in...

  1. Steve says:

    thanks … cant help but wonder why this capability (report dbase schema) isnt supported in even the most basic fashion



Leave a Reply

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


You may use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>