This is the code I'm using to insert multiple pictures in worksheet, problem is that it inserts picture in active cell. I want it to add pictures only at range A50:D65, what do I need to do to make this go right?
And also, is it possible that pictures are one below another? One picture in row 50, another on row 51 etc. ??
this is the code;
Sub InsertPictures()
Dim Pict() As Variant
Dim ImgFileFormat As String
Dim PictCell As Range
Dim lLoop As Long
Dim sShape As Picture
ActiveSheet.Protect False, False, False, False, False
ImgFileFormat = "All Picture Files(*.emf;*.wmf;*.jpg;*.jpeg;*.jfif;*.jpe;*.png;*.bpm;*.gif;*.gfa;*.emz;*.wmz;*.pcz;*.tif;*.tiff;*.cgm;*.eps;*.pct;*.pict;*.wpg;*.pcd;*.pcx;*.cdr;*.fpx;*.mix), *.bmp"
'Note you can load in any nearly file format
Pict = Application.GetOpenFilename(ImgFileFormat, MultiSelect:=True)
If Not IsArray(Pict) Then
Debug.Print "No files selected."
Exit Sub
End If
Set PictCell = Selection.Cells(1)
For lLoop = LBound(Pict) To UBound(Pict)
Set sShape = ActiveSheet.Pictures.Insert(Pict(lLoop))
With sShape
If .Height < 408.75 Then
PictCell.EntireRow.RowHeight = .Height
End If
' If .Width < 254 Then
' PictCell.EntireColumn.ColumnWidth = .Width
' End If
.Top = PictCell.Top
.Left = PictCell.Left
End With
Set PictCell = PictCell.Offset(1)
Next lLoop
End Sub
Bookmarks