CarloC
CarloC

Reputation: 155

VBA Error handling dosen't work for one user in Excel 2016

I have a weird situation where a user is experiencing a run time error (which is expected and handled) except in this one case. From all the documentation that I've read for VBA error handling, if a sub procedure creates an error, the error is percolated up through the call stack until a procedure is found that has error handling and it is processed at that level. If no handler is found, then the run time error dialogue window is displayed. So...

    Sub ProcedureA()

Try:    

    On Error Goto Catch
    ' No error handler in ProcedureB
    ProcedureB

Catch:

    If Err.Number <> 0 then

        '  Manages error from ProcedureB

    End If

End Sub

This works for all users except one who had recently installed Excel 2016 (although there are other users with 2016 and no problems). In his case, the run time error dialogue window appears with the "scene of the crime" highlight pointing to a statement in ProcedureB (which has no error handler). My question then is if there is some setting in Excel or in its VBA options which would override the default VBA error handling behavior?

Upvotes: 1

Views: 340

Answers (1)

Brandon Barney
Brandon Barney

Reputation: 2392

This isnt an issue with his Excel version. It is instead a setting within the VBE. From what I know, this isnt turned on by default, so either your user turned this setting on, or for one reason or another the default setting changed.

To fix this setting:

  1. Open the VBE
  2. Go to the Tools Menu (Alt-T)
  3. Select Options (Alt-O)
  4. Under the General Tab > Error Trapping you will want to select either 'Break in Class Module' (this allows you to see errors within class modules, if they occur. I highly recommend this setting.) or 'Break On Unhandled Errors' (nearly the same behavior, but it breaks within the calling routine and wont allow you to see the error as it happens within the class.)

Then you should be all set. What was happening was the VBE settings were overriding the error handling behavior which can be beneficial for debugging, but is not so beneficial when someone is actually running your app.

Upvotes: 3

Related Questions