Results 1 to 6 of 6

Userform Combobox to display image name from file

Threaded View

  1. #1
    Registered User
    Join Date
    01-28-2013
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    4

    Userform Combobox to display image name from file

    Hello,

    My user form titled "sinkinformation" has an image box and a combo box. I'd like the image box to display an image based on what is selected from combo box, titled "sinkstyle".

    The following is the code I am using. The problem I encounter is that the combo box will not display the list of file names from the file path specified in the code (C:\sinkstyle). Obviously this means that if the image's file name doesn't populate in the list, there's nothing to select to display that image.

    Private Sub sinkinformation_Initialize()
    
        Application.ScreenUpdating = False
        Dim fA()
        Dim i%, n%
        Dim dName$
        ChDrive "c"
        ChDir "C:\sinkstyle"
        dName = Dir("*.jpg")
        Do While dName <> ""
        n = n + 1
        ReDim Preserve fA(1 To n)
        fA(n) = dName
        dName = Dir()
        Loop
        For i = 1 To n
        sinkstyle.AddItem Left(fA(i), Application.Find(".", fA(i)) - 1)
        Next
        Application.ScreenUpdating = True
        
    End Sub
    
    Private Sub sinkstyle_change()
    
        Image1.Picture = LoadPicture(sinkstyle.Value & ".jpg")
        
    End Sub

    I have checked the accuracy of the file path name, file type (.jpg), and other obvious possible errors which might cause this issue.

    Please let me know if any additional information is needed to better understand my question or code I am using.

    Thank you very much!
    Last edited by Leith Ross; 04-27-2013 at 04:22 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1