Event to detect when Excel gets focus
Hi all,
I’m trying to detect when Excel get focus. Well, actually I’m trying to detect when my workbook gets focus, but I want to detect when the focus is received from a different application.
All of these methods seems to detect when I switch between Excel windows, but not other applications.
vb Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Private Sub Workbook_Activate()
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Private Sub Application_WindowActivate(ByVal Wb As Workbook, ByVal Wn As Window)
Private Sub Application _WorkbookActivate(ByVal Wb As Workbook)
Does someone know how to do this?
Thanks,
-Terry
Cross post here:
http://www.xtremevbtalk.com/showthread.php?t=312278
Re: Event to detect when Excel gets focus
those activate events only fire when a different sheet or workbook is activated in excel
you would have to use some API functions to find if excel gets focus, then run in a timer or something similar
check out GetActiveWindow API
Re: Event to detect when Excel gets focus
Thanks for the input westconn.
I'm not sure about the effects of running a timer, but the gut feeling is that the system will be slowed down a little. The complexity also increases the chance of unexpected behaviour (due to errors or poor overall design).
I don't think I want to go down that path for the sake of a few cosmetic features...
-Terry