I often include images in Visio diagrams, and sometimes they are part of a group shape. There are times when I need to swap the image for another, and I want the correct width to height ratio for the new image to be applied, otherwise the image will be distorted. I recently realised that the Shape.ChangePicture() function in Visio actually returns this ratio which can then be applied to the shape cells so that the image is not distorted. Therefore I wrote some C# code (in LinqPad) to utilize this method to provide the option to change the image in a selected shape or sub-shape.
So, I wrote this function in C# to swap the image of the shape, and to apply the formulas to maintain its correct aspect ratio, even if the shape is subsequently resized.
Automation
Visio Automation for IT Design & Operations – London, 25th April 2018
I am pleased to announce that I will be co-hosting a free event at the new Microsoft Reactor in Shoreditch on 25th April, aimed at showcasing Visio automation for IT design & operations. You can find more details and sign up here.