I have several images on a worksheet. I want to resize them all to the same size, but I can\'t seem to get it working quite right. I thought it would be like the code below, b
I think you're only missing a minor thing. By default (when I test it) images inserted to the sheet have LockAspectRatio=True
.
You need to set this to False
, otherwise the changes may be unpredictable: if you step through the code using F8 you can observe that Width
changes, but then on the next line Height
reverts the width change from previous.
So, set this to false and the images should retain the specified width/height.
Option Explicit
Sub ChangeAllPics()
Dim s As Shape
Dim ws As Worksheet
Set ws = ActiveSheet
For Each s In ActiveSheet.Shapes
s.LockAspectRatio = msoFalse
s.Width = 500
s.Height = 200
Next s
End Sub