Everyone knows that you can change the colour of Visio shapes. Most people know that you can also change the fill pattern too.
The Fill dialog displays these bits of information as Color, Pattern and Pattern color. However, the ShapeSheet stores them as FillForegnd, FillPattern and FillBkgnd. The following screenshot is displaying the Values of the cells, which displays the RGB values:
The actual formula for a colour though, may reference a particular theme, or it could be a number from the color map, for example 2 usually means Red (or RGB(255,0,0)).
Some Visio users may wish to display the RGB values in Shape Data rows so that these values can be analysed or reported.
So, I have added some code to the bVisualUtilities.vss that I started in my last blog about automatically updating Shape Data with Area and Perimeter Lengths (see http://bvisual.spaces.live.com/blog/cns!3350D61BC93733A9!2214.entry )
First. I added some constants to the bVisualMetrics module:
Then, I added the AddUpdateFillsTrigger() to add some cells to the Page and selected shapes.
Finally, I added the UpdateFills() method that actually updates the Shape Data in the shapes whenever the FillForegnd, FillPattern or FillBkgnd values are changed.
You can download the stencil that contains the VBA code here : http://bit.ly/cJYwdP
So, to use this, just Run the AddUpdateFillsTrigger macro whilst your desired shapes are selected.
This macro will three Shape Data rows to the selected shapes, which will display the RGB values of the Foreground and Background, plus the formula of the Pattern.
It is then a simple matter of using Data Graphics, as I showed in the earlier blog article, or Insert Field, as shown below, to display the Shape Data row values in the shape (don’t forget that you can enter text, field values and multiple rows in a text block):
Once this has been done to a ew shapes, then you easily use the built-in Visio reporting tool to list the shapes and their fills:
Not long now to the release of Visio 2010, but all of the code in this blog will work on any version and edition that I can think of.