You'd need to sub-class Excel's window and trap messages, a lot more than
one API but you should find examples by Dan Appleman. However, in theory
doable in VBA (I haven't attempted) but most likely to crash as soon as you
touch the VBE while the code is running!
If it's really important for you, and it's OK to have code permanently
running, you can safely report all messages to Excel's window(s) with a
C-dll and a fair amount of VBA. More details here -
http://groups.google.co.uk/group/mic...3?dmode=source
I forgot to include in that post, in the bas module I included following in
the MessageEvent proc (this is where you'd include your own code to respond
to new state of Excel's window)
Public Sub MessageEvent(arg's
Dim winState As Long, sWn As String
winState = Application.WindowState
If winState = xlMaximized Then
sWn = "Maximised"
ElseIf winState = xlMinimized Then
sWn = "Minimized"
Else
sWn = "Normal"
End If
On Error Resume Next
'If uMsg Then
Debug.Print "MSG : hWnd = " & CStr(hWnd) & "," _
; uMsg = " & GetMsgSTR(uMsg) & ", _
wParam = " & CStr(wParam) & ", _
lParam = " & CStr(lParam)," _
; "WinState = " & sWn
'End If
also, experiment to filter which messages you are interested in
Regards,
Peter T
"Greg Lovern" <(E-Mail Removed)> wrote in message
news:63bae9ac-ddcd-4391-8d5d-(E-Mail Removed)...
> Is there any way to be notified when the Excel application is
> activated, after some other application was the active application?
>
> I've enabled the Excel application-level events, but none of them fire
> when the Excel application is activated.
>
> Is there a Windows API function I can use? I looked at Appleman's
> Win32 API book but didn't see one.
>
>
> Any suggestions?
>
>
> Thanks,
>
> Greg