multiple error handler fail in form image properties

CsJHUN

Active Member
Joined
Jan 13, 2015
Messages
360
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
  2. Mobile
Hi guys i have this:
Code:
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)Application.ScreenUpdating = False
On Error GoTo kov 'I need this error handler becasue some users are not macro friendly.... :)
ActiveSheet.ShowAllData
kov:
Cells.Find(What:=ComboBox1.Value, After:=Range("C10"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
aclr = ActiveCell.Row - 10
'...
'load a barrowful of data from sheets into form textbox
'...

On Error GoTo 0 'tried with this and w/o this not helped


On Error GoTo pacikaki[U] 'this error handerdont want to work[/U]
Me.Image1.Picture = LoadPicture("some intranet address" & ComboBox1.Value & ".jpg")
CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"
Exit Sub


pacikaki:
MsgBox ("hiba a képpel, szinte képtelenség!")
CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"


End Sub

The picture loading is working if the picture is present in the given directory, but if its not the "On Error GoTo pacikaki" is not going to "pacikaki"
I would like some help from you, what m i missing?

Cheers
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
At least in that last bit that you asked about, it looks to me as though you simply want to pass over the error if there is one (with a message box advising). If that is the case, try:

<font face=Courier New><SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>Me.Image1.Picture = LoadPicture("some intranet address" & ComboBox1.Value & ".jpg")<br><SPAN style="color:#00007F">If</SPAN> Err.Number = 53 <SPAN style="color:#00007F">Then</SPAN><br>  MsgBox ("hiba a képpel, szinte képtelenség!")<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0<br><br>CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"</FONT>

I would suggest reading/studying: On Error WTF? | Excel Matters

Hope that helps,

Mark
 
Upvote 0
Code:
[FONT=Courier][COLOR=#00007F]On[/COLOR] [COLOR=#00007F]Error[/COLOR] [COLOR=#00007F]Resume[/COLOR] [COLOR=#00007F]Next[/COLOR]
Me.Image1.Picture = LoadPicture("some intranet address" & ComboBox1.Value & ".jpg")
[COLOR=#00007F]If[/COLOR] Err.Number = 53 [COLOR=#00007F]Then[/COLOR]
  MsgBox ("hiba a képpel, szinte képtelenség!")
[COLOR=#00007F]End[/COLOR] [COLOR=#00007F]If[/COLOR]
[COLOR=#00007F]On[/COLOR] [COLOR=#00007F]Error[/COLOR] [COLOR=#00007F]GoTo[/COLOR] 0
CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"[/FONT]
Not worked, but used the on error goto -1 and now its do what i wanted, the final code
Code:
....
On Error GoTo -1
On Error GoTo kephiba
Me.Image1.Picture = LoadPicture("some intranet address" & ComboBox1.Value & ".jpg")
On Error GoTo 0 'maybe this is not even needed now
CreateObject("WScript.Shell").Popup TextBox2.Value & " adatai beolvasva", 1, "Info"
Exit Sub
kephiba:
Me.Image1.Picture = LoadPicture("")
MsgBox ("hiba a képpel, szinte képtelenség!")
End Sub
Thank you GTO!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,432
Messages
6,119,468
Members
448,900
Latest member
Fairooza

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