How to pop up information on double-clicking a shape

Started by kovenna, November 27, 2017, 01:41:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kovenna

I am creating business process flows in Visio 2012. I can write reasonable VBA but I am stuck trying to find shape events so that I can create a popup (with textual information in it) when double clicking a shape. Is this possible to do? Is there another way of doing this that does not involve using VBA?

Many thanks

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

vojo

can also do from shapesheet

eventdblclk = docmd(1312)

wapperdude

#3
Depends upon what you want as a "trigger".  As Vojo indicates, in the shapesheet, there is the doubleclick event.  There are quite a few DoCmd functions in addition to the 1312.  Here's link to the most recent list:  https://msdn.microsoft.com/en-us/vba/visio-vba/articles/docmd-docmd-commands.  You can google for other lists that are for specific Visio release.

Paul's solution goes a step further than the DoCmd functionality.  His link gives a good explanation.

Another shapesheet avenue is the "right" mouse click event which brings up a customizable list of definable responses.  In the shapesheet, this is the Actions section.  Typically, it is not shown, so right click anywhere in the shapesheet to bring up a menu to add sections.  A list of shapesheet functions is provided here: 
https://msdn.microsoft.com/en-us/library/office/ff768297.aspx
A good summary reference by John Goldsmith:  http://visualsignals.typepad.co.uk/files/visio-shapesheet-functions-by-version.pdf

If you are truly looking for shape events, that will take code.  You can search this forum as I recall some effort to do some specific event handling.  You can also download the free SDK software which has many code examples, and I believe event monitoring.  And, of course, use google.

Wapperdude.
Visio 2019 Pro

kovenna

Thanks Everyone. Paul's download looks useful but only where I am the Windows Administrator...so no good at work unfortunately.
It does strike me as strange that there are no shape events?! What is the good of having Office VBA when a chunk of functionality is just ruled out in one of the products?
Bit disappointing. :(

metuemre

Visio is really flexible, most of the time there are more than one way to do things. Attached is a simple example for your needs.

kovenna

Yep, that's exactly what I'm looking for 
Thanks metuemre

Ain't forums grand?  8)

kovenna

Arrgh! Spoke too soon..

So, in your Visio file, metuemre, if I add say a Flowchart basic shape and double click it...nothing happens.
But in the code, the line that seems to control this behaviour is

Set shp = ActiveWindow.Selection.PrimaryItem

The shape ID = 1 but I cannot see anything that links the popup launch to your shape in particular.
What am I missing here?

metuemre

You are welcome kovenna  ;)

When you double click the shape in my example it triggers the formula in EventDblClick shapesheet cell. In order to open shapesheet of a shape you need to enable developer mode.
http://www.visguy.com/2015/06/19/how-to-show-the-developer-ribbon-tab-and-why/

If you check that cell you will see the formula "CALLTHIS("Module1.HelloWorld",)" which calls a sub with a name of "HelloWorld" in Module1 when triggered.
If you check that sub you will see that it opens Userform1
If you check Userform1 you will see that a reference is set to the selected shape and its properties are shown on userform.

So if you want your Flowchart shapes to act like this, you need to add the formula to EventDblClick cell of those shapes and write necessary codes to related Module and Userform.


kovenna