Kuyenda
Kuyenda

Reputation: 4609

What event fires if Excel VBA code execution is prematurely ended?

Is there an Excel Application or Workbook event that fires if code execution is ended from a run-time error?

I use Application.Interactive = False at the beginning of some of my procedures. If the code execution stops before Application.Interactive = True at the end of the procedure, then the user gets locked out of the Excel.

I don't want to use On Error GoTo Error_Handler or On Error Resume Next, because I want the error window to show (for the time being).

I want to add Application.Interactive = True to some event that fires when code execution is stopped, or the code module is reloaded.

Thanks!

Upvotes: 1

Views: 410

Answers (1)

Fionnuala
Fionnuala

Reputation: 91366

What have you against an error handler?

For example:

Sub DoStuff
On Error GoTo Error_Handler

    ''Do stuff

Exit_Here:
    Application.Interactive = True
    Exit Sub

Error_Handler:
    MsgBox Err.Number & " " & Err.Description
    Resume Exit_Here
End Sub

Upvotes: 4

Related Questions