I've managed to find VBA code that inserts multiple images at once in to a column of cells (predefined size).
However, the images consist of landscape and portrait orientations. I want to lock the aspect ratio to cell height. Is there any way to do this? It's especially a problem for the portrait oriented images which get stretched to the horizontal dimensions of the cell.
Ideally, all aspect ratios are kept, with cell height as the benchmark.
Thanks a lot!!
My code when selecting the first cell:
Sub InsertPictures()
Dim PicList() As Variant
Dim PicFormat As String
Dim Rng As Range
Dim sShape As Shape
On Error Resume Next
PicList = Application.GetOpenFilename(PicFormat, MultiSelect:=True)
xColIndex = Application.ActiveCell.Column
If IsArray(PicList) Then
xRowIndex = Application.ActiveCell.Row
For lLoop = LBound(PicList) To UBound(PicList)
Set Rng = Cells(xRowIndex, xColIndex)
Set sShape = ActiveSheet.Shapes.AddPicture(PicList(lLoop), msoFalse, msoCTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height)
xRowIndex = xRowIndex + 1
Next
End If
End Sub