Hi, can anyone help. I've gone through a tutorial whereby I was able to use a combo box to load a graphical illustration and tried utilising it in my own userform.
I changed the references from combobox1 to combobox2 etc but I cannot get the box to show the files, I'm confused as it works fine in my experimental workbook. It may have something to do with the initialise instruction because the userform is fired by a button, but not sure.
Any help would be much appreciated. Here's the code:
I changed the references from combobox1 to combobox2 etc but I cannot get the box to show the files, I'm confused as it works fine in my experimental workbook. It may have something to do with the initialise instruction because the userform is fired by a button, but not sure.
Any help would be much appreciated. Here's the code:
Code:
Private Sub UserForm1_Initialize()
Dim fs, f, f1, fc, s
Dim folderspec
folderspec = "\\SVR2\Data\Common Folders\Technical & QA\CAD\Images for labels\"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
ComboBox2.Clear
For Each f1 In fc
ComboBox2.AddItem f1.Name
Next f1
ComboBox2.SetFocus
ComboBox2.ListRows = 20
Application.SendKeys "^{F4}"
End Sub
Private Sub ComboBox2_Change()
Image1.Picture = LoadPicture("\\SVR2\Data\Common Folders\Technical & QA\CAD\Images for labels\" & ComboBox2)
End Sub