Keeping the aspect ratio lock working with VBA

Started by Visisthebest, April 14, 2022, 07:59:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

When I set the Aspect Ratio lock on a shape:

Shape.CellsSRC(visSectionObject, visRowLock, visLockAspect).FormulaU = "1"

it works with the UI but not if I set shape width directly, with

Shape.CellsU("Width).FormulaU = "1 in"

for instance. The aspect ratio is changed. Is there a way to change the size via VBA of a shape where the Aspect Ratio lock just corrects the other dimension automatically to keep the aspect ratio unchanged?
Visio 2021 Professional

Yacine

This is definitely a bug!

As work around you may check for this protection (shp.Cells("LockAspect").ResultIU = 1) and correct the other dimension accordingly.

As this would be tedious to write in your regular code and you may forget it, a function could help

eg instead of targeting the width or height directly, you would call a "setWidth" / "setHeight" function.
Yacine

Visisthebest

Good to know this is a bug, I just added an aspect ratio correction to my code but was indeed surprised that the aspect ratio isn't enforced for code changing width or height.
Visio 2021 Professional

Paul Herber

I suppose it is a bug of a sort, but it's probably designed behaviour right from the start, so changing it might break stuff.
Electronic and Electrical engineering, business and software stencils for Visio -

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

Yacine

#4
Jein (= Ja and Nein = Yes and No).
Whilst there will always be situations where you'll need to prevent stuff to break, you still have a (kind of) responsibility of keeping the logic understandable and consistent.
In this case, at least a warning, would notify the user of unsuitable commands.
Not the finest of what they've done so far.
Yacine