Runtime Error 53 file not found

valasso

New Member
Joined
Jun 15, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi All
I am new to forum and a noob with vba / macros i have checked other posts regarding this error but it has not helped. So if i post my code can someone please lead me in the right direction please.

Background
I have a worksheet with forms and on the forms i have a multilevel combo-boxes. When you select Combo1 you then get a selection that you can choose from in Combo2 once you select a item it should fill in the image bozx with the item you selected and this works as you continue to fill out the form all is fine and at the end when you click the submit button it writes the info to another sheet in the workbook which it does but it then gives me the error Runtime Error 53 - File not Found. Very frustrating as i do not understand why.

Code add_frm
Private Sub ComboBox1_Change()

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DropDown")

Dim i As Integer

Me.ComboBox2.Clear

For i = 2 To sh.Range("A" & Application.Rows.Count).End(xlUp).Row
If sh.Range("A" & i).Value = "Cabinet Name" Then
If sh.Range("C" & i).Value = Me.ComboBox1.Value Then
Me.ComboBox2.AddItem sh.Range("B" & i).Value


End If


End If


Next i

End Sub

Private Sub ComboBox2_Change()
Image1.Picture = LoadPicture("C:\Anertex" & "\" & ComboBox2.Value & ".jpg")
'Image1.Picture = LoadPicture(ThisWorkbook.Path & "\" & ComboBox2.Value & ".jpg")' - -- i have aslo tried this
End Sub


All the files exists in the correct path and while in the form it does show you the correct jpg.. Thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Do you get an error at all when this line is commented out? Image1.Picture = LoadPicture("C:\Anertex" & "\" & ComboBox2.Value & ".jpg")

Thinking maybe your ComboBox2.value is null at a certain point and it might be throwing the error?
 
Upvote 0
Thanks for your reply
Yes when that line is commented out it all works but i do not understand why this 1 line throws up this error.
 
Upvote 0
You could add a file check like below, but I believe it's something to do with combobox2 being null after it runs.

VBA Code:
Private Sub ComboBox2_Change()
    Dim FullFilePath As String
    
    FullFilePath = "C:\Anertex" & "\" & UserForm1.ComboBox2.Value & ".jpg"
    
    If Dir(FullFilePath) <> "" Then
        Image1.Picture = LoadPicture(FullFilePath)
    End If
    
End Sub
 
Upvote 0
Thanks for your reply QR I will add this code and see how it goes. I believe your correct in regards to the combo2 maybe be null. When thinking of the what happens when the code is run, my thought is with the UserForm and the multilevel combobox it places the correct text in the box and it does show the correct picture you press the submit button and it does write the info into the worksheet DATA and at the end of the code if i am correct it clears the UserForm and this is when it must see the null value in the combo2 and then throw the error at the end. What do think would you have any thoghts on how to finish that action of submit so it does not look at the combo2 and throw the error. I may have not worded this correctly so please excuse me.
 
Upvote 0
Hi QR
Sorry for the delayed response. I have tried the code you have suggested but it now doesn't show the image. I have tried a few different ways but no go. May i ask do you know a better way of trying to display a image in a userform using a mutlilevel combobox. Any suggestion is greatly appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,515
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top