Link to home
Start Free TrialLog in
Avatar of Andreas Hermle
Andreas HermleFlag for Germany

asked on

Downsize graphics in Excel whose height is more than 4 cm, using VBA

Dear Experts:

below macro, courtesy of RGonzo1971 of EE, batch inserts graphics into Column D. The corresponding paths are located into Column C.

This macro is neat and concise and works just fine.

I now would like to get this macro expanded as follows:

If the graphic's height that gets inserted in any of the cells in Column D is is more than 4 cm, the graphic has to be downsized to 4 cm max Height.

All the pictures that get inserted have already the property 'aspect ratio constrained'

Help is much appreciated. Thank you very much in advance.

Regards, Andreas


Sub InsertPicture()
'Macro by RGonzo1971, EE
'Insertion of Graphics in Column D. Corresponding paths are stored in Column C
'
For Each c In Range(Range("C2"), Range("C" & Rows.Count).End(xlUp))
    c.Offset(0, 1).Activate
    ActiveSheet.Pictures.Insert ( _
        c.Value2)
Next
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Andreas Hermle

ASKER

Hi Rgonzo,

wow, I am truly impressed :) Thank you very much for your great and professional help.

Regards, Andreas