DasWolf60652
New Member
- Joined
- Jul 15, 2015
- Messages
- 9
Hey everyone,
Rory helped me last time get the declaration correct for my function but now my colleague wants to maintain aspect ratio and orientation but still have all the pictures the same size.( either legal or landscape orientation)
I can maintain original aspect ratio by having -1 for both width and height in my Addpictures step.
But in the With shp step, I think I need to use an IF statement to have excel determine whether the width is longer than the height and then set the correct orientation size from there.
Is this possible with my current function or should I have a different function for retrieving the photo information and then divide by cell ratio?
Rory helped me last time get the declaration correct for my function but now my colleague wants to maintain aspect ratio and orientation but still have all the pictures the same size.( either legal or landscape orientation)
I can maintain original aspect ratio by having -1 for both width and height in my Addpictures step.
But in the With shp step, I think I need to use an IF statement to have excel determine whether the width is longer than the height and then set the correct orientation size from there.
Is this possible with my current function or should I have a different function for retrieving the photo information and then divide by cell ratio?

Code:
Function insert(PicPath, counter)
Dim shp As Shape
With ActiveSheet
Set shp = .Shapes.AddPicture(Filename:=PicPath, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
Left:=Range("B" & counter).Offset(2, 0).Left, Top:=Range("B" & counter).Offset(2, 0).Top, _
Width:=-1, Height:=-1)
End With
With shp
.LockAspectRatio = msoTrue
.Height = 210
.Width = 150
.Placement = 1
End With
End Function