Utilizza la API GetForegroundWindow

Private Declare Function GetForegroundWindow Lib "user32" () As Long

al posto della GetActiveWindow