With this event:
https://learn.microsoft.com/en-us/office/vba/api/visio.shape.shapeparentchanged
and a bit of simple code, I can see whether the user is performing a shape grouping or ungrouping.
What I want to achieve is, I want to check:
1. If the shape is being grouped (simple)
2. If the shape is of a certain type (simple)
And if so, cancel the grouping being performed completely and show the user a messagebox telling him/her why the grouping is cancelled. (these shapes don't work as expected if grouped)
Is it possible to cancel a grouping completely after catching this event? (this event may fire many times when performing grouping, once for each shape, I'd like to cancel the grouping the first time I catch this event being performed on a specific shape type).
Thank you for sharing your insights!
I think I need to capture this slightly unclearly named event:
https://learn.microsoft.com/en-us/office/vba/api/visio.shape.querycancelgroup
something like:
groupingrequested
(these are user-initiated events, so groupingrequestedbyuser is even more explicit and clear)
is from my perspective a clearer event name because it is clear a grouping of shapes has been requested (by the user), a request which can be granted but also stopped/denied by the automation.
It is named "...cancel..." because cancelling (or interrupting) is the main purpose of the event. ;)
Yes that's true, but the name can also suggest you're querying whether a grouping cancellation is occurring.