Life with Visio and other Microsoft Toys!

Highland Fling

leave a comment »

A while back I was intrigued by some Lego mini-figures that one of the US MVP leads had given to some of her MVPs. This started me on a project to create a Visio Lego man. It also started me thinking on what a Visio mini-figure of me would be like. Considering my heritage, my mini-figure had to have a kilt. Kilts/skirts for Lego mini-figures is very easy. It is just a rectangle with a tab with two holes to go over the pins on the top of a Lego block. The rest of the kilt/skirt is just folded around the brick. So, making a kilt should just be a matter of finding an image of a tartan. Unfortunately, I could not find an image of the tartan I wanted with enough squares to make a kilt. No problem, I could just make my own as a Visio custom fill pattern. Initial trials showed that I needed to better understand the pattern. The brute force method meant a lot of shapes that would severely impact performance. If I was going to create a Visio custom fill pattern, I might as well do it in such that the method could be used for other tartans. So I turned to my favourite list handler, Excel. I could use Excel to create the tartan and then use SnagIt to capture the pattern. Something the US lead would approve of.
So, what is a tartan? it is a pattern based on setts, groups of coloured threads in a given order and specific thread counts. The pattern is the same in the horizontal and vertical. What you end up is a set of squares that match when the same colour threads intersect and rectangles of two mixed colours. Since this is a two up to down pattern. the mixed colours form a zigzag pattern.
In addition to being able to handle lists, Excel could handle colours. In the past, I needed to handle lists of colours and Excel was well suited for the task. I could create the fill colour for a cell based on RGB values in the same row. Sort the table and the RGB and the colour sample remained together.
So, I created an Excel workbook with a worksheet of colours, a worksheet to hold possible setts and a pile of values for sets and of course, a worksheet of instructions. The workbook also contains VBA macros to manage the colours and the setts and to create a tartan in an empty worksheet.

You can obtain the workbook from one of the Canadian Excel MVPs, Debra Dalgleish.


John Marshall… Visio MVP


Written by johnvisiomvp

February 12, 2018 at 3:47 am

Posted in Uncategorized

Call me Sheldon – Fun with Flags

leave a comment »

I am always looking for new Visio shapes and I found a collection of Flags  in SVG format. They are not complete and some of them lack the actual embellishments on the flags, but it is a start. Though not quite a one stop shop as this page is, I did find some more detailed SVGs by Googling “FLAG country-name SVG”. This took me to more detailed shapes. So, I started converting/making Visio shapes.

SVG is a good starting point for creating Visio shapes, but it has it’s limits. Some are by the nature of SVG and some are by decisions of the shape creator. So, now I have almost 200 country flags as Visio shapes. So why Visio shapes rather than just clip-art? With real Visio shapes, they can stretch. So you can have a tiny flag or a huge one. Enlarging clip art can result in jaggies. Unfortunately, not all the flags are perfect. This is a rundown of some of the issues.

So, creating a flag is easy. The simplest is the surrender flag, a simple white rectangle. You do not even have to worry about the aspect ratio. … but it is not a country flag. The next easiest would be Japan, a red circle on a white rectangle. It is just a matter of getting the right colour of red, the aspect ratio (height to width) of the flag and the ratio of the diameter of the circle to the width of the flag.

Then comes the two colour flags like Poland, a rectangle split in half. This can easily be created by a red rectangle and a white rectangle. As long as you use a grid line to position the shapes, it is no problem to join them with no overlaps or gaps. There are a number of other two colour flags, but they have embellishments (like Malta) or crosses (like Finland) where in addition to the colour and aspect ratio, you need to know the thickness of the lines in the cross. Another way to create the two colour flag is to create the rectangle of the full flag, create a line bigger than the shape, align them so the line is centered and then fragment. For a simple two colour shape, this is over kill, but the technique is useful on flags with more stripes. This is also a useful technique if the dividing line is at an angle (like Jamaica – though again, you need to know the width of the stripe).

The tricolour flags can be created by the same rectangle and line technique, but this time you will need four parallel lines. So duplicate a line three times align on the edge, distribute the lines and then group. Resize the group so it matches the rectangle and make sure that the line ends extend beyond the rectangle. select both shapes and align. Though not necessary, you should select the top and bottom line from the group and delete them. This is just in case your group and rectangle are not the same size and you do not want slivers. Select the rectangle and grouped lines and fragment. You will now have three adjacent rectangles you can colour. Finish off by grouping the flag.

So far we have yet to use SVG files except to determine colours and aspect ratios.

For flags like the US, do the same thing with the lines. I will talk about the star field later. With multiple strips, you have the option of replacing the individual lines of one colour with a single rectangle of that colour the size of the flag to use as a background. The alternate colour will hide portions of the flag to make it appear that the other colour is striped rather than solid.

So, that is some of the basics for creating flags, but before we look further, we should establish some guidelines. What size should the flags be? Flags have various aspect ratios, so the common property I am going to standardize on is a height of one inch. If they are true Visio shapes, then holding the Ctrl key and stretching should not be a problem. The next guideline is to minimize the shapes. Some flags have crosses, there is no need to have two rectangular shapes to create the crosses. Some flags seem to have bands that appear to be a colour stripe centered on top of another coloured stripe. Kenya is an example of this, a red stripe on top of a white stripe. This can be handled by three separate rectangles or a rectangle on top of a bigger rectangle. Which is my preferred solution. It is one less shape.

The SVG shapes are close, but not perfect. Either by SVG limitations or the designer, there are problems. Some of the shapes distort on stretching, and are made up of more basic shapes than are necessary. Some even have cross shape references that also distort the shape. The first clean up step is to  ungroup the shape, and then ungroup the shape… until there are no more groups, just individual shapes. Following Visio Guys recommendation, the result will be rebuilt as a single group. -> Minimize groups, minimize shapes.

The Union Jack is an interesting shape, and appears in several flags of the Commonwealth. So, I will start with converting one of the SVG versions to a proper Visio shape.  One problem with this SVG version of the shape is that the diagonals are made of 1d shapes, so the ends are not clean. Rather than match the flag outline, the line ends are at 90 degrees to the line. So, all the lines have to be replaced by rectangles and the resulting shape trimmed with a rectangle the size of the flag. When finished, we will have a basic Union Jack that can be used in other flags.

The Union Jack has a width of 60 units and a height of 30 units. Each blue corner is 25 units by 10 units. The white cross is 10 units and the red cross is 6 units. The white diagonals are 6 units. and the red diagonals are 2 units.

One thing that people find out when they try and draw the Union Jack is that the red diagonals are not centered. So, you can actually have a Union Jack upside down. So, if you divide the white diagonals from the top left in to six strips, then the 2nd and 3rd strip will be red. The red strip is not continuous over the center, it switches. When you cross the center, it is the 4th and 5th strip that are red. Going from the bottom left, it is still the 2nd and 3rd strip as red and 4th and 5th after the center.

So, a Union Jack flown properly and not in distress mode will have the large white stripe at the top next to the flag pole. If you can not cheat and use an Australian flag as a reference, all flags  that are meant to be raised on a flagpole will have a toggle on the top side of the flag so it can be attached to the rope that will haul the flag up and the bottom side will have a rope to secure the bottom end of the flag to the rope that hauls the flag up.

The stars in the SVGs were interesting. They were made up of triangles. I did try Union on the triangles, but that left gaps. So, it was a matter of selecting the shapes and doing a fragment. reselect the shapes and do Union. Selecting the shapes may be tricky because it may include the background. You need to start the selection property outside the flag and drag across making sure you do not select unnecessary shapes. When dealing with flags like the US that have a field of stars, you can select the entire star field and do a fragment, reselect and do a union.

Crescents were another group of shapes that were made of a collection of simple shapes. In this case, circles. These can be selected, fragmented and the excess shapes deleted. Remember the idea is to minimize the number of shapes for performance.

So, the collection I have got it is not perfect. I have not verified all the colours used or whether the aspect ratios are correct, but it is a start. I have put a sample of the flags in the MSDN Gallery. I am not sure what I will do with the full collection, but I am hoping at some point Microsoft will have a store for Visio shapes and stencils.


John Marshall… Visio MVP

Written by johnvisiomvp

February 12, 2018 at 3:24 am

Posted in Uncategorized

Colour My World Part II

leave a comment »

Visio does not handle rows well and lists easily in the shapesheet, you can not do basic things like sorting the rows. So I use my favourite list handling app, Excel. When I need to manage large amounts of shape data, I manage it in Excel and then use VBA to remove the old shape data and populate the shape data section from Excel. I also use Excel to handle arrays within the shape data so the various lists remain in sync.

Here is the earlier experience Colour My World

On one of my project I also had to have the shape data in sync with an xml file. With Excel, that was easy. Just add a new column for XML and populate it with a formula that combined the column headers as part of an XML tag with the correct data. It did require a bit of finesse getting an XML column into a single string, but even there I was assisted by a Word VBA macro to remove the extraneous tabs.

In the first blog I talked about handling a handful of colours. I unfortunately got carried away and started to search the net for more colours that had names. The result was that I had more than 4,700 colours. There were a number of RGB values that had several names and several names that had multiple RGB values. There was also a few lists that could stand on their own, Lego colours, HTML colours, Crayola colours, Wikipedia colours, ColorHexa and Pantone Colours. Most of the Pantone colours did not have common names and Crayola has changed the names of some the crayons over the years. I even found some VBA code that would generate a worksheet of the colour spectrum showing the RGB values at various frequencies. Some of the lists also included hyperlinks to more information. The Colours spreadsheet contains a list of all the colours, but not their hyperlinks.

In the search for lists of colours and names, sometimes I got names and RGB values, sometimes they were names and RGH hex values and even times with there was a name and sample but no values. Luckily the colour samples, when copied into a worksheet. The colour samples became the cell fill colour. So I needed a toolbox of VBA code and cell formulas to manage the list.

The aim was to get a worksheet with a column for the colour name, columns for the R,G&B values and a column for the hex of the RG&B value. I also wanted to colour the cells with the hex value as a sample of what the colour looks like.

So I used the following code to extract the RGB values from the cells fill colour.

Function getRGB(rCell As Range, Optional opt As Integer) As Long
' =getRGB(D14,1)=getRGB(D14,2) =getRGB(D14,3)
Dim C As Long
Dim R As Long
Dim G As Long
Dim B As Long
C = rCell.Interior.Color
R = C Mod 256
G = C \ 256 Mod 256
B = C \ 65536 Mod 256

If opt = 1 Then
getRGB = R
ElseIf opt = 2 Then
getRGB = G
ElseIf opt = 3 Then
getRGB = B
getRGB = C
End If
End Function

If you want to recreate the hex value of the RGB code, use

The following code will set the fill colour of a column based on the R, G and B values in other columns.

Public Sub ColourCells()
Dim LRow As Long
Dim rCell As Range
Dim rng As Range
Dim SH As Worksheet
Dim Threshold As Integer

Set SH = ActiveSheet
With SH
LRow = .Cells(Rows.Count, "B").End(xlUp).Row
Set rng = .Range("B2:B" & LRow)
End With
For Each rCell In rng.Cells
With rCell
.Offset(0, 3).Interior.Color = RGB(.Value, .Offset(0, 1).Value, .Offset(0, 2).Value)
End With
Next rCell
End Sub

What I noticed was that the text in the colour sample did not show up when the colour was dark. So I added another column called Obverse to indicate that with that colour, the text colour must be black or white. I did change the code in the ColourCells macro to set the value for Obverse and also apply it to the text. The results were okay. The first attempt set the value if the R,G&B values were all less than a certain threshold. Since this was done in code, I will take more time tuning the values.

One of the things I was trying to do with the list was to get the colours sorted in a pleasing manner. Initially I tried to sort by RGB, but there was a banding effect as the values of RG&B changed, especially when a value jumped from 255 to 0. I also tried to match the spectrum as can be seen in the Spectrum worksheet. It is a pleasing result, but it does not map to the named colours. I also tried mapping to the Hue with some results, but again there were banding issues. I even tried a fudge by grouping values together. Again,  there was only slight improvements. So for now I am leaving sorting alone.

I could leave the lists as a mixture of values and formulas, but I was concerned with performance from all the recalculations. So all the columns were copied to new columns  and pasted as values. 

I have asked one of the Excel MVPs to host the workbook. I will update this post when it is live.

John Marshall… Visio MVP

Written by johnvisiomvp

November 14, 2017 at 11:05 am

Posted in Excel, Shapes, Uncategorized, VBA, Visio

Tagged with , ,

Updated Pool Table

leave a comment »

It looks like the original pool table shape had a problem with internationalization. I have updated the shape and the issue has been eliminated.

In the original designed I used lists to control the colour of the cloth. One list was used  to present colour options to the user by displaying names of colours. The second list was a list of the RGB values those colours represented. When the user was presented with the list of colours I would get an index of the colour in that list. I would then use that index to get the RGB value from the RGB list. I had another user cell that contained the RGB value that was retrieved from the RGB list.

The problem appears that though I can place a text string of an RGB value in the foreground colour cell and it worked, but in French, German and Russian* it would be set to black. In the original Visio there were 24 colours numbered from 0 to 23. Later, it was possible to enter any RGB value to get a wide palette of colours. So, when the formula failed it returned a value of zero, which in Visio means black. Testing also showed that entering unquoted RGB values in the Foreground cell in other languages worked. Was it a matter that Visio was applying internationalization rules to colours?

* It is great to have friends who have Visio installed in these languages on their machines.

The workaround I used was to replace the string of RGB values with a list of unquoted RGB values.

I was able to simplify the shape into a single shape with a User cell containing a text string of an RGB value and the Foreground cell pointing to it.

So, if you had this problem with my shape, try downloading an updated version.


John Marshall… Visio MVP

Written by johnvisiomvp

August 4, 2017 at 6:50 pm

Posted in Shapes, Uncategorized, Visio

Tagged with ,

Security Badge update

leave a comment »

I have taken another look at the Security Badge Visio shape I uploaded to the Technet Gallery and though it was passable, I could have done better.

The shoulder and the head in the picture  were two separate shapes so they were joined. As Visio Guy is always stressing the fewer shapes or groups, the better. The White bars, the hole and the picture background were all separate shapes and they were replaced by punching holes in the background. A new shape was added behind the shape so that there was a background visible through the holes.

Changing the background of the badge was always tricky if you changed the shape colour, all the sub shape colours also changed. In this new shape colour I “Guard” the black colour of the silhouette.

Minor point, but I changed the bounding box of the shape. I ungrouped the shape and then regrouped all but the metal clip. I then locked the LockCalcWH in the Protection section of the shape before adding the clip to the group.

The original download of the shape was as a stencil, but I have switched it to a drawing. So you just drag and drop to add the shape to your collection. If there were more shapes, I would have left it as a stencil.

So what can the shape be used for? If you are creating a workflow, you can indicate that a certain security level is required or it can be used to indicate that a badge is being created. It can also be used for a Data Graphic, that can be embellish a shape with different colours of security badges to indicate that a certain security level is required. (Go for it JDP)


John Marshall… Visio MVP

Written by johnvisiomvp

July 25, 2017 at 6:49 pm

Posted in Uncategorized

Pool anyone? … or how to create a smart Visio Shape

with 3 comments

One of the things I like about Visio are smart shapes. The trouble is that most of what is offered as Visio shapes is no more than clipart encapsulated in a Visio shape. For most purposes, that is fine, So time for some real Visio shapes.

A pool table is a good candidate for a smart Visio shape. There are several varieties o table, but they only differ by length and width. So how do create this shape?


The place to start is to do a search on as much information as possible to work out all the dimensions, markings and colours. This will give you an idea of the type of variations that can be handled by a smart shape.


The basic shape may be intimidating with all the finicky details around the pockets, but it is basically two rectangles and size pocket shapes. Okay, two pocket shapes. One for the dise and one for the corners, You basically need to look at it through an artist’s eyes. Paint the background and then paint the pockets on top. The background is basically a brown rectangle to represent the rails and a smaller green rectangle to place on top. No need for trying to fit the cloth around the pockets. The pockets are just painted on top. Think overlays. Rather than try to trim the cloth around the pockets, treat it like a basic rectangle and cover it with the pockets.

Visio shapes are limited in colour and line weights so to get a more varied shape, it will be necessary to group several shapes. Of course, there is over head, so limit the number of shapes and the number of levels of groups to one. The top level (or group shape) should contain all the UI to the user and the sub shapes should use their User sections as an interface to the top level. You could wire the sub shapes directly to the top shape, but is a mess if the shape is ungrouped.  By providing the user cells as an interface, it is easy to restitch if it is ungrouped.  (Of course, I do not always follow my own advice. )

So what makes this shape smart? It has two custom properties, (for now). One controls the table length and the other the colour of the cloth. All tables have a length Width ratio of two to one, so only one dimension is needed. The sizes listed are the ones I was able to find. The lines on the table are based on tables I found and it turns out that there is no formula for the location of the baulk or the D line or the actual radius of the D. The fourty or so cloth colours are based on sales brochures I found, so some of the colours may be pushing the taste of some customers. Of special note, black lines on a black cloth has visibility issues, so the colour of the markings changes to white. A later version may have a custom property to control the line colour. The line colour, width of the bumpers, line position and D radius are all User data cells that can be changed. A User cell is the stay at home cousin of Shape Data, AKA Custom properties. Hidden from the public and less versatile.

Do not forget the accessories. Though the primary reason is to create a shape to represent a pool table in a floor plan, that does not mean you can not use it for other things. With the right accessories, you can use the shape as a training tool setting up possible scenarios and ho to play them. Fodder for the next blog…


)for now)

A copy of the Visio drawing is in the Technet Gallery  Pool Table


John Marshall… Visio MVP

John Marshall… Visio MVP

Written by johnvisiomvp

July 24, 2017 at 3:11 am

Posted in Shapes, Uncategorized, Visio

Tagged with ,

Colour My World

leave a comment »

When I was working on the Windows 7&8 phone apps I created a Visio template to help design phone apps. As usually, it was a Visio stencil that was a bit more than dragging and dropping clipart. One of the WP7 and WP8 features it replicated was accent colours that were set on the phone and were applied to the apps. If you changed the Accent colour any object that used the Accent colour would change.
The technique I used was based on a technique demonstrated by Mark Nelson. The original Visio was based on a palette of 24 colours that were enumerated 0 to 24. Mark’s technique used a Lookup formula in the colour cell that looked up the colour in a list. It basically used the list to find the index of the colour.
The instructions are to put this formula in the FillForegnd cell.
Lookup will match the value of the custom property (the old name for Shape Data) Status to the list shown above. The value returned by Lookup will be a number, starting with 0, which corresponds to the position of the matched value in the list. The list shows Visio’s numbering sequence for the first couple of colours. As I said, there were 24 originalcolours, So the list of colour string can be extended to add the missing colours.

If the Status property choices are “Warning”, “Caution” and “Clear”, in the Lookup formula, replace the words “Red”, “Yellow” and “Green” with “Warning”, “Caution” and “Clear”. You must leave the other colours in as place holders to get the correct colour position. Actually, you should keep the list of colours as a comment so that if you want add or change the colours or strings you have a template for their placement. The final formula would be:

This is fine if the colours you want are in the original 24 colours of the Visio colour palette. Luckily Visio has been extended so in addition to the original colour names you can use a string in the colour cell as long as it evaluates to an RGB value. So now it is a matter of manipulating strings.
In Mark’s solution, everything was within one formula. The string manipulation will require a few more cells. So, what cells and where should they be placed? Most of the strings do not have to be available to the user, so User cells rather than Shape Data cells makes more sense. A Shape Data cell will be required to let the user choose the colour. In Visio there are three shapesheets that can be used. In addition to the shapes’s shapesheet there is a page and a document shapesheet. To reference the document stencil, precede the cell name with TheDoc! And use ThePage! As the prefix for the page. To actually access these shapesheets go to the Developer tab. There is a dropdown for each shapesheet on the ribbon. So why use them? If you have an item that is referenced several times on a page or many times in a document, placing it in the shapesheet with the appropriate scope makes sense. The value is in one location and maintenance is reduced. Do you really want to be hunting through a document to find out where a list is used to change a value? Use a reference and keep a single copy of the value.
So, to solve the limitation on colours, I create two user properties. Both were lists (Type 1 shape data). One list was the names and a the other was a matching list of the RGB values. I could have placed these values in the User Data section for the shape, but I placed them in the User data for the document. So any shape in the document could use these values. The difference between a User property and a shape data property is that the user property is hidden from the user.
I put the reference to an occurrence of the colour in the Page Shapesheet. So the control of the Accent colour is at the page level. So if I change the accent colour, all shapes on that page using an accent colour will change. I chose the page level because I may want to have different accent colours on different pages.
So, the Document shapesheet would have two user data cells:
User.WP7Colours =”Magenta;Purple;Teal;Lime;Brown;Pink;Mango;Blue;Red ;Green”

User.WP7ColoursRGB =”RGB(255,00,151);RGB(162, 00, 255);RGB(00, 171, 169);RGB(140,191, 38);RGB(153, 102,00); RGB(233,113,184);RGB(240, 150, 09);RGB(27, 161, 226);RGB(229, 20, 00);RGB(51, 153, 51)”

Or for the Windows phone 8 accent colours
User.WP8Colours =”Amber;Brown;Cobalt;Crimson;Cyan;Emerald;Green;Indigo;Lime;Magenta;Mauve;Olive; Orange;Pink;Red;Steel;Taupe;Teal;Violet;Yellow”

User.WP8ColoursRGB =”RGB(240,163,10);RGB(130,90,44);RGB(0,80,239);RGB(162,0,37);RGB(27,161,226); RGB(0,138,0);RGB(96,169,23);RGB(106,0,255);RGB(164,196,0);RGB(216,0,115);RGB(118,96,138);RGB(109,135,100); RGB(250,104,0);RGB(244,114,208);RGB(229,20,0);RGB(100,118,135);RGB(135,121,78);RGB(0,171,169);RGB(170,0,255); RGB(227,200,0)”

The Page shapesheet would have one user cell:
User.WP7AccentColour =INDEX(LOOKUP(Prop.WP7AccentColour,TheDoc!User.WP7Colours),TheDoc!User.WP7ColoursRGB)

Or for the Windows phone 8 accent colours
User.WP8AccentColour =INDEX(LOOKUP(Prop.WP8AccentColour,TheDoc!User.WP8Colours),TheDoc!User.WP8ColoursRGB)

And a Shape Data cell :
Prop.WP7AccentColour Type=1
Label = Accent Colour 7
Format =TheDoc!User.WP7Colours
Value =INDEX(5,Prop.WP7AccentColour.Format)
Prop.WP8AccentColour Type=1
Label = Accent Colour 8
Format =TheDoc!User.WP8Colours
Value =INDEX(9,Prop.WP8AccentColour.Format)

In the actual shape shapesheet Fill Format section the FillForegnd cell would be ThePage!User.WP7AccentColour or ThePage!User.WP8AccentColour.

So if you need to add colour palettes to a shape or group of shapes you can create two lists, one for the name of the colour and the other the RGB values. Treating the colour as a string, create a shape data to hold the value and assign that string to the appropriate colour cell. Where you place the user cells or shape data cells is dependent on whether the colour palette is limited to a shape or to a page or a document.
I have added a sample Visio drawing in the Technet Gallery.


John Marshall… Visio MVP

Written by johnvisiomvp

July 8, 2017 at 6:15 pm

Posted in Shapes, Uncategorized, Visio

Tagged with ,