I have a question. Currently i am working on a sort of catalogue in excel where i also use vb codes. The user can easely search for products using an productnr. It shows all the specifications of that product. All this information is used out of another database.

Secondly i used a VB code to copy all the information into a list, this is for clients to easely makean orderlist.

i have only one problem, in the first part i referred to the specifications of the product but i also really want to show the picture of that product. All these pictures are saved in one folder, and i have the names of these productphoto's also in the other database. I thought of a code that searches in the folder for the photo with that name and than show the picture?
Does anybody have a clue and knows something for this problem??


6 Years
Discussion Span
Last Post by vb5prgrmr

See the Dir Function in the help files to check for the existence of a file...

If Dir(FilePathName) <> "" Then
  'file found
End If

Good Luck


Thanks for replying! I ve been working on the code but it seems that i cant get it right.
For example: i want to put in a command button to show the picture(so the picture come up in a seperate window)
i am a beginner but i am a fast learner..
the name of the picture is in cell a1..

i cant get any further then..

Private Sub CommandButton1_Click()
Private Sub Image1_Click()
Range("A1") = LoadPicture("C:\Users\Media\Pictures")
End Sub

End Sub

can you help me?


Ahhh... I see... I think I do anyways... Okay, as far as I know, you cannot set the reference to a cell to a picture box or a picture...

You will need to have a form and we will call it UserForm2 for now... Then on UserForm2 you have a picture/image box/control (In vba it would be a image control). So we will call this Image1

(BTW: Don't forget to use the code tags like I have below...)

Private Sub CommandButton1_Click()
Dim F As New UserForm2
Load F
F.Image1.Picture = LoadPicture("PathFileName") 'or is that image???
End Sub

Now the above code will create a new instance of form2, load it, load the picture into the image control, and finally show it...

Good Luck

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.