4
Good afternoon,
I have a spreadsheet, where I need to automatically include images. I wonder if there is any way to elaborate a macro, where you join the Reference and color (reference & color) and search in a certain folder the photo related to that code.
Ex:
In the macro it is possible that when there is no photo in the folder named with (reference & color ex: 60557000156) it can jump and continue inserting photos for the next?
Existing macro: The macro that I use in other materials to search images is this below, but it needs to be repeated for each image I need, previously there were at most 20 images, but now for each page are at least 78 images and each excel tab has at most 6 page which results in approximately 468 images, so I look for a more summarized macro;
Sub Macros2()
Call Imagem1
Call Imagem2
Call Imagem3
'...
Call Imagem20
End Sub
Sub Imagem1()
Range("B11").Select 'This is where picture will be inserted
Dim picname As String
picname = Range("A6") 'This is the picture name
ActiveSheet.Pictures.Insert("\\storage\Img_Systextil\PROJETO LUNENDER\Fotos RPN\Inverno 2018\" & picname & ".JPG").Select 'Path to where pictures are stored
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This resizes the picture
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
With Selection
.Left = Range("B11").Left
.Top = Range("B11").Top
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.Height = 150#
.ShapeRange.Width = 150#
.ShapeRange.Rotation = 0#
End With
Range("A10").Select
Application.ScreenUpdating = True
Exit Sub
ErrNoPhoto:
MsgBox "Unable to Find Photo" 'Shows message box if picture not found
Exit Sub
Range("B20").Select
End Sub
Yes. It is possible. As far as you have come with your attempt?
– Diego Rafael Souza
Good afternoon Diego. I could not develop anything for this spreadsheet in question, what I always did was to use an existing macro in another file and adapt to the new materials, because I am quite inexperienced in this subject. The macro I use needs to be repeated within the programming for each image I use (e.g. if I have 20 images I will have to repeat 20x) in this new file is another 500 images, so I can’t reuse it. I wonder if you can help me?
– Luana Della Giustina
Put the code you have today, this macro there that needs to be repeated. Maybe from it we can help. But as the question is now, will probably be closed as too wide
– Diego Rafael Souza
posted on the question.
– Luana Della Giustina
@danieltakeshi I think you’re right. I’ve reviewed it and it’s not quite a duplicate. I’ll withdraw the vote..
– rLinhares
Possible duplicate of Add photo in excel spreadsheet from local folder
– danieltakeshi