Show Message Box If Shape is Selected - Without Running a Macro

Started by Leonardo, August 28, 2017, 02:25:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Leonardo

Hello,

Do you know if it's possible to create personals events on Visio ?

I'm asking this question because i would like to right a code which could open a msgbox when a shape is selected. (without run my macro. )...... Like this, users will select any shapes and read a msg on the msgbox.

thk you,
Best.

Leonardo

Yacine

look for the event selectionChanged in the thisDocument of module of the document.
Yacine

Leonardo

The event is not in the document. To use it, i have to use AddAdvise method...

Are you sure for this event ? I read that in the Microsoft site : "Occurs after a set of shapes selected in a window changes"

Leonardo

Quote from: Yacine on August 28, 2017, 04:18:12 PM
look for the event selectionChanged in the thisDocument of module of the document.

Maybe are you talking about the event SelectionAdded ?

wapperdude

I rarely use events, so won't comment on which to use.  But I do question the "advisibility" of triggering a Visio response every time a shape is selected.  Any time you do something, a shape is selected...2D, 1D.  That trigger mechanism will be firing constantly. Yikes!

Wapperdude
Visio 2019 Pro

Paul Herber

How about activating the message box when the shape is double-clicked?
Electronic and Electrical engineering, business and software stencils for Visio -

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

doone

You can also use the Comment field in the Miscellaneous section of the shape sheet.  It's like a tool tip on a mouse hover event.

Yacine

Wapperdude and myself played with a hover routine some while ago. (http://visguy.com/vgforum/index.php?topic=6012.0)
Eventually I recalled this post and had some spare time to build up a small visio sandbox around the idea.
Have a look at it. It shows also the use of the selectionChanged event.

Hint: saving the document switches the animation on and off.

HTH, Y.
Yacine

Visio Guy

Have a look at the space/office planning shapes. When you select a wall shape, it displays a built-in dimension (length number).

This is an example of an add-in responding to shape selection events, and setting a flag in the ShapeSheet of a shape when it happens. You can even demonstrate that the code is incomplete by breaking it:

1. Open a Home Plan or Office Plan diagram
2. Select a wall shape (the dimensions show)
3. Copy the shape
4. Open a new diagram (not a "plan" template)
5. Paste the shape
    The dimensions for the wall will remain "always on", since the new document does not have the support of the add-in.

Note also in the undo buffer, you will see "Select Shapes". Normally, selecting shapes in not an undoable action, but the add-in is flipping a flag inside the shape, which causes undoable stuff to happen.

You can also confuse it by having multiple windows open. When you click a different window, the SelectionChanged event doesn't fire, and the selected wall doesn't get deselected, so the dimensions remain visible.

I have code for my own SelectionChanged event that fires when different windows are activated, so that shapes can be cleared of special selected behaviors.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Leonardo

Quote from: Paul Herber on August 29, 2017, 03:33:14 PM
How about activating the message box when the shape is double-clicked?

Yes it could be interesting.. The interest is to interact with the shapes without executing macro.

Paul Herber

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

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