• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • Last Modified:

Load Image from Listbox Change Event

excel 2010 vba...

I need a function to activate during the Change event for a listbox.
I passing variable for the value to load an image will be in column(0) in the listbox.

What I need:

When a user scrolls in the listbox  a new image is displayed depending on the value in Column(0) in the listbox.

The path for the images file are in:


trying to get this to work..

Dim Gsku As String
    Dim fPath As String
     'selects the range to look for a name.  You have to have a range
     'named  myName set up on column A.  Go to insert-name-define to
     'see how this one is set up.
    Gsku = ListBox1.Column(0)
        On Error Resume Next
        If Gsku Is Nothing Then
            Image1.Picture = LoadPicture(fPath & "NOTAVAIL.JPG")
                'Look in the directory where this workbook is located.
                fPath = "C:\MyPics"
                On Error Resume Next
                 'If a matching picture is found then display it.
                Image1.Picture = LoadPicture(fPath & Gsku & "_AS01.jpg")
                 'If No picture found then display the default picture.
                If Err = 0 Then Exit Sub
                Image1.Picture = LoadPicture(fPath & "nopic.gif")
        End If
  • 4
  • 2
1 Solution
NorieData ProcessorCommented:
Does the code you posted not work?

One thing I can seet that might cause problems is the missing end \ from fPath.

Try adding it.
fPath = "C:\MyPics\"

Open in new window

FordraidersAuthor Commented:
aaah ...Crazy  Thanks
FordraidersAuthor Commented:
during the change event I want to clear the pic for each change ?

this: Image1.Picture = Null

or this: Image1.Picture = "" 

is not working...
Sorry to ask again.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

NorieData ProcessorCommented:
The 2nd code should work.

Are you getting an error?
FordraidersAuthor Commented:
FordraidersAuthor Commented:
nm , its workin correctly...
my bad..

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now