I found the following with pretty much does what is wanted -
'Written: February 14, 2011
'Author: Leith Ross
'
'NOTE: This code should be executed within the UserForm_Activate() event.
Private Declare Function GetForegroundWindow Lib "User32.dll" () As Long
Private Declare Function...