1

I have searched and experimented with multiple answers to my question, but they don't seem to work. I have a database that prints to word a photo and text for each record. The information is presented in a table format, with the pic/image located in a row in the table. The images are created and saved by multiple users and are not all the same size. The database is resizing the images to a predetermined size that I do not want. I want to macro to resize all the images to 3.5" in height. I don't really care about the width, but want the aspect ratio to be locked. I have found some answers, but the aspect ratio solution doesn't seem to work. This component of the code ".LockAspectRatio = msoTrue" seems to be ignored when the macro is run. As a result, the image gets distorted or stretched. Any help would be greatly appreciated.

Here is the code I'm currently using, but I've tried some others:

Sub ResizePhotos() Dim pic As InlineShape

For Each pic In ActiveDocument.InlineShapes
    With pic
        .LockAspectRatio = msoTrue
        If .Width > .Height Then ' horizontal
            .Height = InchesToPoints(3.5)
        Else  ' vertical
            .Width = InchesToPoints(5)
        End If
    End With
Next

End Sub

3
  • 1
    I'd suggest using Image Magick imagemagick.org/index.php to resize them all outside of VBA for best quality. As to your macro, we can't help you with it if you don't provide it; please click edit and paste the macro text into your question. Please don't use Add Comment for it has no formatting; please instead use edit. Editing tips are at superuser.com/editing-help#code
    – K7AAY
    Sep 30, 2019 at 20:32
  • 1
    The comment has been edited. Thank you for responding!
    – J Chapman
    Oct 1, 2019 at 11:37
  • Just circling back. Does anyone have a solution?
    – J Chapman
    Oct 3, 2019 at 11:53

0

You must log in to answer this question.

Browse other questions tagged .