Best way to get absolute position of subshape on Page

Started by Visisthebest, January 11, 2021, 08:06:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

For some user functionalities in VBA I worry that a user has grouped shapes together while my VBA subs/functions assume they are on the page (all shapes I use are already grouped shapes).

My subs/functions assume these shapes have a PinX/PinY relative to the page so if the user groups the shapes, and the PinX/PinY become relative to the group, things go haywire.

It would be great to be able to block grouping on certain shapes (already happy I can block ungrouping), but maybe even better to always read the absolute PinX and PinY (on the page) of my shape so I don't have to worry the user has grouped them.

What is the best way to do this? Thank you for your advice!
Visio 2021 Professional

Visisthebest

Solution I came up with now is to check the formula for PinX and PinY, if they are not just numbers (absolute position on the page) but contain a reference to another (the group) shape, then I inform the user the software first has to ungroup the shape group he's made before continuing.
Visio 2021 Professional

Nikolay

You can use shape.XYToPage to convert local coordinates to page coordinates.

Visisthebest

Thank you Nikolay I was completely unaware such a function is available!
Visio 2021 Professional