Page 1 of 1

[Solved] "On Error" question

Posted: Wed Mar 19, 2008 4:25 pm
by Lazy-legs
Hello,

I can't figure out how to use the On Error GoTo handler correctly. In the following macro, the idea is that when the browser is not found in the specified path, an error message appears. The problem is that the message pops up even when there is no error.

Code: Select all

Sub Main()
On Error goto EH
Shell("C:\Program Files\Mozilla Firefox\firefox.exe", 1, "http://www.openoffice.org")
EH:
MsgBox("Couldn't find the browser.")
End Sub
As always, what am I doing wrong?

Thank you!

Kind regards,
Dmitri

Re: "On Error" question

Posted: Wed Mar 19, 2008 4:42 pm
by Villeroy

Code: Select all

Sub Main()
On Error goto EH
  Shell("C:\Program Files\Mozilla Firefox\firefox.exe", 1, "http://www.openoffice.org")
Exit Sub
EH:
  MsgBox("Couldn't find the browser.")
End Sub

Re: "On Error" question

Posted: Wed Mar 19, 2008 4:52 pm
by Lazy-legs
Perfect! Thanks, Villeroy.

Kind regards,
Dmitri