Resize an image with VBA?

B

Brad Zenner

I'd like to create a macro to make an inserted image automatically resize to
3.5" tall, but when I record a macro the code automatically populates the
width to a specific dimension also, which could possibly distort the image.

I'm new to VBA, so I was wondering if it's possible to write code to resize
the height of an image programatically so that it will adjust the width
proportionally? I don't expect anyone to write it for me, just let me know
if that's possible. If it is, I'll make an attempt (with a guide book in
hand...) and ask the group if I get stuck.

Thanks in advance for any help/suggestions.
 
J

Jezebel

Get a reference to the image. Then either set the LockAspectRatio property
to true and set the height, or recalculate the width and set the height --

Width = OldWidth * NewHeight / OldHeight
Height = NewHeight

You'll need to convert the units -- width and height are in points.
 

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