Inserting pictures from folder using macro

- - Latest reply: ac3mark
Posts
10909
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
December 7, 2018
- Oct 24, 2018 at 03:57 PM
Hello,

I would appreciate if someone would help me. I never used macro until today and I searched for a solution but I just don't understand.

This is what I need to do:
I have excel sheet that has inventory numbers in column A. In A2 is number 11111, in A3 11112 and so on. In folder on computer I have pictures named by inventory numbers, so 11111, 11112, 11113...
I need to write macro that will insert pictures in column F based on inventory numbers. So if in A2 is 11111 then in F2 should be picture named 11111.

I'm very grateful for every response.

Best regards,

Nives
See more 

Your reply

1 reply

Posts
10909
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
December 7, 2018
0
Thank you
Well good luck with this. Excel is for calculating complex mathematical equations, not an interface for images. Even if the code will insert it into the row and column you wish, if the images are not all the same size, it will WRECK the formatting of your columns, making them unreadable.

Which part of the scripting are you having issues with?

Here is short code for you to play with in the sandbox!

Sub insert()
picpath = "e:\pictureshare\smiley1.jpg"
With ActiveSheet.Pictures.insert(picpath)
With .ShapeRange
.LockAspectRatio = msoTrue
.Width = 75
.Height = 100
End With
.Left = ActiveSheet.Cells(1, 20).Left
.Top = ActiveSheet.Cells(1, 20).Top
.Placement = 1
.PrintObject = True
End With

End Sub


Respond to ac3mark