Hi
try this
Code:Sub InsertPic() Dim I As Long Dim xPath As String Dim xShape As Shape Dim xRg As Range Dim xFiles Dim j As Long Dim a As Range xPath = "L:\test\" xFiles = Array("1.jpg", "2.jpg", "3.jpg") If Dir(xPath & "*.jpg") = "" Then MsgBox "Picture file was not found in path!", vbInformation, "test" Exit Sub End If For I = 1 To ActiveWorkbook.Sheets.Count Set xRg = Sheets(I).Range("B10:C10,D10:E10,f10:g10") For j = 1 To xRg.Areas.Count Set a = xRg.Areas(j) Set xShape = Sheets(I).Shapes.AddPicture(xPath & xFiles(j - 1), True, True, a.Left, a.Top, a.Width, a.Height) Next Next End Sub




Reply With Quote
Bookmarks