[Solved] "On Error" question

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
Lazy-legs
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

[Solved] "On Error" question

Post 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
Last edited by Hagar Delest on Tue Jun 10, 2008 2:01 pm, edited 2 times in total.
Reason: tagged the thread as solved.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: "On Error" question

Post 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
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Lazy-legs
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

Re: "On Error" question

Post by Lazy-legs »

Perfect! Thanks, Villeroy.

Kind regards,
Dmitri
Post Reply