Site icon bVisual

More secrets of the Visio Legend shape

I was going to do a full post on the special Legend shape in Visio that can automatically count instances of masters on a page, then I found that my good friend Chris Roth, aka VisGuy, had done one some years ago ( see visguy.com/…/legend-shapes). However, I have some extra information that will assist in getting the functionality to work consistently.
Basically, you can make any Master work with the Legend shape by adding the User.visLegendShape = 2 setting into a Master shape, but there are caveats.

  1. If the name of a Master is changed, then any existing shapes on the page must be re-placed
  2. The BaseID of each Master must be unique
  3. If the BaseID is changed (using NewBaseID), then any existing shapes on the page must be re-placed

To demonstrate this, I used the Good and Bad icon shapes from the Legend Shapes stencil.

1 / 6



I then created a new shape and dragged it onto the Legend shape. This action then makes a new Master in the document stencil and inserts the User.visLegendShape row with a value of 2. This new Master name is added to the count in the legend, but the name is incorrect. So, I then edited the name of the master, but the Legend still shows the old name. When I deleted the existing shape instances of the new master, and then re-added them, they then got shown correctly in the Legend shape, with the new name.
In the second test, I duplicated the Good master, which was then automatically named Good.9.


Simply adding instances of this to the page merely updated the count for the original Good icon, and no extra line was created. I renamed the Good.9 Master as Excellent (after making the smile bigger!), but the Legend shape did not update still (as expected after the first test). In this case, however, deleting any existing shape instances and replacing them still did not create a new Legend line.
I then checked the BaseID of the Good and Excellent Masters with the Immediate Window in the VBE, and saw that they were identical. I then request a new BaseID for the Excellent master with the NewBaseID property. Then I replaced the existing shapes, and everything worked fine.
This should solve some of the issues that users have found with the Legend shape.
 
 
 
 
 

Exit mobile version