Graham to the Rescue

This week I was bored and decided to create a new collection of Visio shapes. It should be an easy task, some of the shapes were just block letters in a circle.

This was a single shape that could be one of those four letters. Since I wanted to save the Shape Text for something else I created the letters as block shapes. That was easy to do.

Since Chris AKA Visio Guy is always pushing for minimalism, I wanted to create the new shape as a single shape rather than a group shape of those four shapes. Unfortunately, copying Geometry Sections or any ShapeSheet section is NOT a feature of Visio.

Luckily I remembered some wise words from Graham Wideman, the author of the must have set of books on Visio development. He was having a problem removing VBA macros from a Visio file and ended up opening the XML and deleting the VBA project XML.
Problem solved.

So what about doing the same thing to combine the Geometry section? It can not be that hard to copy and paste the relevant XML code?

In the old days it was a matter of saving the drawing as an XML, but now Visio has a new format. This is even easier. The new format is a zipped folder of XML files. So, to remove the noise, I copied the shapes to a new Visio drawing, saved it, changed the extension to ZIP and uncompressed. Then it was just a matter of editting page1.xml. Rather than cut and paste, it was easier, just delete the unwanted XML.

So find the end of the first Geometry section in the first shape and delete to the start of the first Geometry section of the next shape. Repeat for the rest of the shapes. The only cleanup needed was renumbering the new Geometry section.

Saving the changes, rezipping the file and changing the extension back to VSDX. The result was

It still needs some shapesheet magic to hide the unnecessary Geometry sections, but it took far less time than it took to blog about it.

One concern was that Visio sometimes closes the loop on a shape by setting the last row to point to the first Geometry2.X1 and Geometry2.Y1

Luckily the XML contains more than a reference name, it contains the values, so it was just a matter of deleting ” ‘F=Geometry1.X1’ “.

I hope this helps.

John… Visio MVP in x-aisle

Published by johnvisiomvp

The original Visio MVP. I have worked with the Visio team since 1993