Jump to content
Sign in to follow this  

Error Handlers?

Recommended Posts


I need information on creating error handlers.

I tried search on the forum, but I can't find one that explains error handlers

I need to create a error handler that deal with COM errors

Share this post

Link to post
Share on other sites

Pasted from the AutoIt Help file. Search for COM Reference.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler 

; Performing a deliberate failure here (object does not exist)
$oIE = ObjCreate("InternetExplorer.Application")
$oIE.visible = 1
if @error then Msgbox(0,"","the previous line got an error.")


; This is my custom error handler 
Func MyErrFunc() 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription ) 

   SetError(1) ; something to check for when this function returns 

Share this post

Link to post
Share on other sites


The thing I want to do though is automatically generate a report on excel.

Like it works, but randomly I'd get the COM error.

I want it to be automatic, so I want it to try again. Like 5 times before the program exits.

Do you have any idea of how to do that?

Also, how do you release a varaible.

Because I'm using someone else's UDF

And they're not releasing their Error Handler.

And the help file says that there can only be one Error Handler at a time, so I need to release the previous Error Handler.

Edited by NewtonScripter

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this