Page 1 of 1

Catching macro error

Posted: Mon Feb 25, 2008 7:22 pm
by Lazy-legs
Hello,

I have a simple macro that opens a browser specified in a Global variable:

Code: Select all

Global Const DefaultWindowsBrowser="C:\Program Files\Mozilla Firefox\firefox.exe"
Shell(DefaultWindowsBrowser,1, LookupWord.String)
As you can see, the path to the browser is hard-wired, so if you use other browser than Firefox, or the browser is installed in a different location, the macro won't work. How do I "catch" the error, so I can make do macro something useful if the browser is not found in the specified path? I hope my question makes sense.

Kind regards,
Dmitri

Re: Catching macro error

Posted: Mon Feb 25, 2008 8:23 pm
by JohnV

Code: Select all

Global Const DefaultWindowsBrowser="c:\Program Files\Mozilla Firefox\firefox.exe"

Sub FF
On Error goto EH
Shell(DefaultWindowsBrowser,1,"String")
End
EH:
MsgBox "Error # " & err & ": " & error$ + chr(13) + "In line : " + Erl
End sub
My Firefox is located where you have it. If I change the drive I will get error # 53 - FIle not found. If I leave it alone and use LookupWord.String I get a Variable not set error. If I use "String" then Firefox opens http://www.String.com .

Re: Catching macro error

Posted: Mon Feb 25, 2008 8:27 pm
by Lazy-legs
Thank you, JohnV, for saving my day. Again. :-)

Kind regards,
Dmitri