Jump to content

Error Handlers?


Recommended Posts

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
$oIE.bogus 
if @error then Msgbox(0,"","the previous line got an error.")

Exit 


; This is my custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   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 
Endfunc
Link to comment
Share on other sites

Thanks

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...