I wrote a post a few years ago entitled How to Run VBA Macros from a Ribbon Button in Visio 2010, and was recently asked how to add the custom buttons to an existing tab. Well, it got me thinking that I don’t really like having any VBA code in my Visio diagram documents, so I thought I would explain how all the code can be in a macro-enabled stencil so that it can be used with many different diagram documents. It turned out to be a very easy modification….
[Read more…] about Adding Macro Ribbon Buttons to Visio Documents from a StencilVBA
Referencing Visio Shapes
Every Visio shape must have a unique name in the collection that it belongs to, and to ensure this, Visio automatically one using the master name or just “Sheet”, if not an instance of a master, followed by a period (“.”) and the ID. However, a user can rename a shape, and Visio will then also update the universal name (NameU) to be the same as the Name. If a user chooses to re-name a shape a second time, then thee universal name is not updated … it remains as the original name.
To demonstrate this I drew a rectangle, then named, and re-named it:
[Read more…] about Referencing Visio ShapesBi-directional Labels on Off-Page Grid References
I have previously written about using off-page references and labelled page grids in Visio, see A Page Grid with Labels and Page Grids and Off Page References, however a reader pointed out that the label on the Off-Page Reference shape is duplicated on both ends. This is not always ideal, however it is all I could do using just ShapeSheet formulas alone. So, in this article, I show how a VBA macro can enhance the reciprocal labels on the twin Off-Page Reference shapes, and they automatically update if either end is moved between grids. This is especially useful in electrical wiring diagrams, but the principal can be adapted for other purposes.
[Read more…] about Bi-directional Labels on Off-Page Grid ReferencesAssigning Visio Shapes to Layers from Excel Table
I work a lot with layers in Visio, and written an add-in, LayerManager, to assist, but I was asked an interesting question recently: How can shapes by assigned to layers automatically from a list in Excel? So, I thought I would present my solution. This particular request was for a Timeline diagram, where the Milestone shapes are to be on specific layers. So, I just used one of the samples provided with Visio.
[Read more…] about Assigning Visio Shapes to Layers from Excel TableReplacing Images in Visio Shapes by Changing Data
I wrote an article last year about Swapping Images in a #Visio Shape manually, but I want to be able to do this whenever a Shape Data value changes. This is because I use I invariably use shapes linked to data. I also want to be able to have multiple images within a single grouped shape, and all of them changing when their referenced Shape Data values change. I believe that this will be more adaptable for a lot of scenarios than trying to repurpose Data Graphic Icon Sets ( see Make Your Own Visio Data Graphic Icons Sets … automatically). I also discovered that the Shape.ChangePicture(…) function can just as easily work with urls as it can with network file paths, so even more possibilities are opened up! For example, the Visio Online JavaScript API has the ability to overlay an image (see ShapeView.addOverlay(…)).
So, I have created some macros to provide quick and easy selection, positioning and updating of images within a group shape.
I decided to present this article with VBA code rather than my preferred C# so that a stencil could be downloaded to provide instant usability, rather than having to install an add-in. It can be download from Image Utils.vssm, and should then be placed in to My Shapes folder, so that it becomes available to open in Visio. When it is opened, then the macros will need to be enabled.
There are just five public macros:
Formatting Shape Data in Visio
One of the best aspects of Visio is the ability of shapes to hold data, and the easiest way to do this is to define rows of Shape Data. Each row can be defined as holding one of eight different types, and most of these can have their values formatted for display. In this article I discuss the formatting of these values, using either ShapeSheet functions or automation methods. The driver for this is my on-going frustration with the Microsoft provided standard Shape Data window because of its shortcomings … for example, its lack of multi-line support even though it can hold 64k characters in each row, and its lack of a time control, even though it can store dates and time.
[Read more…] about Formatting Shape Data in Visio