Reputation: 464
I am trying to figure out if there is a way to call a macro to clear the status bar after the execution of a different macro. I realize that I can simply use:
Application.Wait(Now + TimeValue("00:00:05"))
Application.StatusBar = False
However, what I want to do is have my original macro end by saying something as:
Application.StatusBar = "Macro Function Complete."
Call clearStatusBar
End Sub
Sub clearStatusBar()
'I do not want the application.wait here because it locks up the excel program.
Application.Wait(Now + TimeValue("00:00:05"))
Application.StatusBar = False
End Sub
Is there a way to delay the "Application.StatusBar = False" while still allowing the user to access the program?
Let me know if you need more clarity. Thanks for your help.
Upvotes: 3
Views: 11777
Reputation: 464
Sorceri was able to provide me with the correct method for my request. By using the Application.OnTime method, you can call your macro on a delay without tying up the program.
Application.StatusBar = "Macro Function Complete."
Application.OnTime Now + TimeValue("00:00:07"), "clearStatusBar"
End Sub
Sub clearStatusBar()
Application.StatusBar = False
End Sub
Upvotes: 2
Reputation:
Sub TestClearStatusBar()
Application.StatusBar = "Testing: ClearStatusBar"
ClearStatusBar
End Sub
Sub ClearStatusBar(Optional ClearStatusBar As Boolean)
If ClearStatusBar Then
Application.StatusBar = False
MsgBox "Cleared"
Else
Application.OnTime Now + TimeValue("00:00:05"), "'ClearStatusBar True'"
End If
End Sub
Upvotes: 7