multiple error handler fail in form image properties

CsJHUN

Active Member
Joined
Jan 13, 2015
Messages
305
Office Version
2016
Platform
Windows
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
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

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
305
Office Version
2016
Platform
Windows
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:

Watch MrExcel Video

Forum statistics

Threads
1,102,856
Messages
5,489,302
Members
407,686
Latest member
Chuck1960

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top