Is the Userform not enough to get the user's attention? Is focus the real issue?
Most people use a Userform, MsgBox or a timed MsgBox as the StatusBar message may be unnoticed.
We could flash the Excel button but Excel's statusbar would not flash. I guess you could change the text at intervals to simulate a sort of flashing.
Here is how to flash the excel application's button using your code:
1. Add to your API module:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long[/vba] 2. In a that Module or another:
[vba]Sub Test_FlashWindow()
Application.StatusBar = "Testing FlashWindow in StatusBar..."
'FlashWindow FindWindow("Excel4", vbNullString) 'Statusbar's classname
FlashWindow FindWindow("xlmain", vbNullString) 'Excel's main classname
Application.StatusBar = False
End Sub
You will notice that the Statusbar message goes so fast that you don't even see it.
You may not even see your Window's Taskbar to see the button flash if you have it set to Auto-Hide.
Here is the flash statusbar message example. The 2nd run beeps at each display.
Sub Test_FlashStatusBar()
FlashStatusBar "Hello World!"
FlashStatusBar "Hello World!", True
End Sub
Sub FlashStatusBar(msg As String, Optional bBeep = False, Optional nLoops As Integer = 5)
Dim i As Integer
For i = 1 To nLoops
With Application
If bBeep Then Beep
.StatusBar = msg
.Wait (Now() + TimeValue("00:00:01"))
.StatusBar = False
.Wait (Now() + 1.15740740740741E-05) 'Same interval as above
End With
Next i
End Sub