Author Topic: Best way to get absolute position of subshape on Page  (Read 469 times)

0 Members and 1 Guest are viewing this topic.

Visisthebest

  • Sr. Member
  • ****
  • Posts: 376
Best way to get absolute position of subshape on Page
« on: January 11, 2021, 03:06:17 PM »
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!
« Last Edit: January 11, 2021, 03:08:31 PM by Visisthebest »
Visio 2021 Professional

Visisthebest

  • Sr. Member
  • ****
  • Posts: 376
Re: Best way to get absolute position of subshape on Page
« Reply #1 on: January 12, 2021, 05:43:54 AM »
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

  • Hero Member
  • *****
  • Posts: 1057
    • UnmanagedVisio
Re: Best way to get absolute position of subshape on Page
« Reply #2 on: January 12, 2021, 07:22:16 AM »
You can use shape.XYToPage to convert local coordinates to page coordinates.

Visisthebest

  • Sr. Member
  • ****
  • Posts: 376
Re: Best way to get absolute position of subshape on Page
« Reply #3 on: January 12, 2021, 07:43:47 AM »
Thank you Nikolay I was completely unaware such a function is available!
Visio 2021 Professional