PDA

View Full Version : Insert Multiple Picture into excel thru vba



dawood
08-11-2020, 12:00 AM
Hi Friends

Hope you are doing good.

I have multiple image files (JPG/JPEG), each image renamed specifically as to which cell number the file has to be inserted (1A, 2A, 3A,4A.....etc) I need a code/ VBA file to perform the above activity. When this code file executed, the image file (1A), will be automatically placed inside the Cell of where the text or picture name written as 1A, and so on. Until all of the file in the specified folder, in the specified filename is attached to the excel.

I had got some vba code in which i can insert only 1 photo also it is not inserting where my picture name exisits.

Thanks

Dawood 2696626966

jolivanes
08-15-2020, 03:49 PM
Maybe try this.
Change the folder references where required.

Sub Maybe()
Dim i As Long, j As Long, filename
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
For j = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
filename = Dir("C:\Folder With Pics\" & ActiveSheet.Cells(i, j).Value & "*")
ActiveSheet.Shapes.AddPicture _
filename:="C:\Folder With Pics\" & filename, _
linktofile:=msoFalse, savewithdocument:=msoCTrue, _
Left:=Cells(i, j).Left, Top:=Cells(i, j).Top, Width:=Cells(i, j).Width, Height:=Cells(i, j).Height
filename = Dir
Next j
Next i
End Sub

dawood
08-15-2020, 11:15 PM
THANKS BRO,IT REALLY WORKS GOOD .....

dawood
08-17-2020, 12:52 AM
Dear Guys,

Thanks for the reply.I am trying to close the thread on proper.Please consider this thread as closed