multiple error handler fail in form image properties

CsJHUN

Active Member
Joined
Jan 13, 2015
Messages
271
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
 

GTO

MrExcel MVP
Joined
Dec 9, 2008
Messages
6,154
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
 

CsJHUN

Active Member
Joined
Jan 13, 2015
Messages
271
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:

Forum statistics

Threads
1,078,252
Messages
5,339,097
Members
399,277
Latest member
Jyoti C

Some videos you may like

This Week's Hot Topics

Top