Visio Guy

Visio Discussions => Programming & Code => Topic started by: Visisthebest on July 06, 2020, 04:06:16 AM

Title: Check this post for a solution for gluing a functional 'button' to a shape
Post by: Visisthebest on July 06, 2020, 04:06:16 AM
From the inspiration I got from this discussion about possibilities to put a 'button' with clickable functionality on a shape:

http://visguy.com/vgforum/index.php?topic=9179.0

I have made the attached demo functionality. Make sure the stencil is open with the drawing as it contains the necessary VBA.

Please find attached a Visio drawing and stencil that together demonstrate how you can create a button that you can glue to (specific) shapes and provide functionality upon double-clicking the button. The 2D gluing means the button travels with the shape as the user moves it around, exactly what I needed.

In the demo, the + symbol shape expand/collapse button only works when glued to the Start workflow shape because it checks both for the NameU and the category to which this shape belongs (vsoShape.GluedShapes(visGluedShapesAll2D, "SuperStart"). Of course you can use another/better way of checking whether the button is glued to the right shape before running specific VBA code.

When double-clicked it will show or hide the entire flowchart from the start button onwards (this is just to demo a visible action resulting from using the button).

What I don't know is if I can also run the VBA on a single click on the 'button', which would be nice to be able to do :).

Remove the button from the start shape and/or glue it on another shape and will let you know it doesn't work because it is not glued to the right shape.

Hope this is useful for someone!