How do I modify the "relative to original picture size" shape option with VBE?

B

Ben Leiran

I have an OLE object (Word Document) that I have added to a worksheet
and I want to resize that object with VBE, but I am having difficulty
with the "relative to original picture size" option. I need to
"uncheck" the "relative to original picture size" option for a shape
with VBE. I can check/uncheck the "Lock Aspect Ratio" box with VBE,
but this does not affect the "relative to original picture size".

Please Help,

Ben Leiran
 
J

J.E. McGimpsey

You don't need to uncheck the checkbox if you're using VBA - it
really only affects how the dialog a) displays the scale factors and
b) uses the scale factors to reset the size. When setting size from
VBA, it has no effect.

For instance, if you set the width and height using the .width and
..height properties, there's no scaling involved so the checkbox
setting doesn't matter - the .width and .height will be set
accordingly. When you open the dialog, if the "relative to original
picture size" checkbox is checked, the scale factor will be
relative, otherwise it will be relative to the current size (i.e.,
100%).

The checkbox does get unchecked if you set the
RelativeToOriginalSize argument to False in the ScaleWidth or
ScaleHeight methods, but you don't need to set it separately (and
I'm not sure if you can).
 
B

Ben Leiran

Thanks for your help J.E.

I was programatically setting the height and width, but was happening
is the text in my OLE Object kept getting stretched. After some
research yesterday I discovered, as you mentioned, I could turn off
the "relative to original picture size" by using the second parameter
in the scaleheight and scalewidth methods. Thus, the code I end up
writing looks something like this...

Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.ScaleHeight 1, False
Selection.ShapeRange.ScaleWidth 1, False
Selection.ShapeRange.Height = 302#
Selection.ShapeRange.Width = 360#

Once again, thanks for all of your help...
 

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