Frozen Status Bar upon Errors

E

ExcelMonkey

I have a procedure that uses the

Application.StatusBar to update the user on the progress
of the routine. As the procedure does not have all the
error handling that it needs, the procedure is failing
every now and then. When it fails, the status bar freezes
with the last value that was in it.

Is there a way to say in the event of any type of error
clear the status bar. I am assuming it would look like

On Error
Application.StatusBar = ""

But I am not sure where to put this in my code as I have a
for Each Loop that calls various procedures. I need to
put it in part of the code that will always ensure that I
do not have values in my status bar upon error generation.
 
J

Jim Rech

You can set a "general error handler" in your main sub and if there is no
error handler set at a given point of execution, error handling will fall
through to it:

Sub Main()
On Error GoTo GeneralHandler
Call Sub1
Exit Sub
GeneralHandler:
MsgBox "in general error handler"
End Sub

Sub Sub1()
Dim x As Integer
Call Sub2
x = "abc" 'will be caught in Main error handler
End Sub

Sub Sub2()
Dim x As Integer
On Error GoTo Sub3Handler
x = "abc"
Exit Sub
Sub3Handler:
MsgBox "in sub3 handler"
End Sub


--
Jim Rech
Excel MVP
|I have a procedure that uses the
|
| Application.StatusBar to update the user on the progress
| of the routine. As the procedure does not have all the
| error handling that it needs, the procedure is failing
| every now and then. When it fails, the status bar freezes
| with the last value that was in it.
|
| Is there a way to say in the event of any type of error
| clear the status bar. I am assuming it would look like
|
| On Error
| Application.StatusBar = ""
|
| But I am not sure where to put this in my code as I have a
| for Each Loop that calls various procedures. I need to
| put it in part of the code that will always ensure that I
| do not have values in my status bar upon error generation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Notepad status bar missing even after Registry entry 0
Status Bar Hangover 3
Status Bar text 3
Staus Bar 2
Status Bar more complex 1
Screen Updating For Status Bar 4
Status Bar 2
Custom Message in Status bar 1

Top