Note that there are some explanatory texts on larger screens.

plurals
  1. POVBA Error Handling not working in Excel
    text
    copied!<p>I have not had much experience with VBA, but I sometimes use it at work. Recently, I have encountered a problem that shouldn't happen, and that neither my boss nor myself can figure out.</p> <p>Basically, the issue is that the <code>Application</code> property <code>DisplayAlerts</code> is set to <code>True</code> by default and can't be changed for some reason. Possibly related is that when I hit an error, it always display the End|Debug|Help alert and never hits the applied error handling.</p> <p>I am running 64-bit Office 2010 on a 64-bit Windows 7 machine. However, I do not believe it to be a platform issue, as I have tested on multiple different platforms, operating systems and software permutations and no other machine has this error; just mine.</p> <p>I have created some sample code in case anyone has encountered this before or has any ideas. The only thing I can think of, is that I have something installed on my machine that is causing this. But after a program purge and many restarts, I am no closer to deciphering what it might be.</p> <pre><code>Public Sub TestErrorHandler() ' Suppress alerts Application.DisplayAlerts = False Dim strArray(1) As String strArray(0) = "Hello" strArray(1) = "World" ' Set up error handler On Error GoTo ErrHandler For i = 0 To 3 MsgBox strArray(i) Next ' Strip the error handler On Error GoTo 0 ' Unsuppress alerts Application.DisplayAlerts = True Exit Sub ErrHandler: MsgBox "Error: " &amp; Err.Description Resume Next End Sub </code></pre> <p>The error is thrown on the third enumeration of the <code>for-loop</code> (as it should). The type of the error is irrelevant, what is relevant is that I get the error and never hit the error handler.</p> <p>Any suggestions or help on this would be greatly appreciated.</p> <p>Many thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload