Lock Picture Aspect Ratio

A

andu

Hi all,
I'm a VBA newbie.
I inserted a polygonal picture into a text with a code like this:

With ActiveDocument.Shapes.BuildFreeform(msoEditingAuto, 342#, 117#)
.AddNodes msoSegmentLine, msoEditingAuto, 297#, 198#
.AddNodes msoSegmentLine, msoEditingAuto, 324#, 288#
.AddNodes msoSegmentLine, msoEditingAuto, 423#, 315#
.AddNodes msoSegmentLine, msoEditingAuto, 504#, 270#
.AddNodes msoSegmentLine, msoEditingAuto, 522#, 162#
.AddNodes msoSegmentLine, msoEditingAuto, 486#, 126#
.AddNodes msoSegmentLine, msoEditingAuto, 342#, 117#
.ConvertToShape.Select
End With
Selection.ShapeRange.Fill.UserPicture "mypath\.mypicture.jpg"

But I don't like that the filled picture is streched somehow in the drawn
shape.
I know that whan doing this from UI there is a checkbox "Lock Picture Aspect
Ration"
that does what I need but how to do it from script?
 
A

andu

No, this will lock the shape's aspect ratio. I need to have the filled
picture locked.
Any idea how to do that?
Regards,
Alexandru.
 
A

andu

In the GUI there is this check box that I can't find how to use
programmatically:
right click on the form/Format AutoShape/Colors And Lines Tab/Color
combobox/Fill Effects/Picture tab/Lock Picture Aspect Ratio

"Selection.ShapeRange.LockAspectRatio = msoTrue" is the equivalent of
checking this:
right click on the form/Format AutoShape/Size Tab/Lock Aspect Ratio

Best regards,
Alexandru.
 
L

LGFN

Hi, I'm not a VBA pro and I really don't know much about VBA, but one thing
that I know you could try; record a macro and do what you need to do manually
 
A

andu

I already did this. As I could see there is no relevand change between the
macro recorded without that check and the one with check from GUI.

Regards,
Alexandru.
 
A

andu

Actually, the fact that I can't see any relevant difference between the 2
scripts (one generated with that check and the other one generated without)
makes me think this check is somehow not available to VBA(not accessible
through scripts) :( ... hope I'm wrong.

Regards,
Alexandru.
 
J

Jay Freedman

Unfortunately, you're correct. There are far too many cases of controls in
built-in dialogs that have no support in VBA. In each release the MVPs have
asked again to have this fixed, but so far without success.

The Selection.ShapeRange.LockAspectRatio property refers to the polygonal
shape created by the drawn lines, not to the picture used to fill it. The
..ShapeRange.Fill property returns a FillFormat object, which has a number of
properties, but none of them have anything to do with its aspect ratio.

One thing I've noticed is that the distortion seems to affect only pictures
that are smaller than the drawn shape; ones that are larger than the shape
are just clipped. If you have the freedom to do so, you can use a graphics
program to embed the smaller picture in a blank background large enough to
fill the shape.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top