Probably, you got anoter window handle. Just use Spy++ to see if that's true.
And/or try this:


HWND hWnd = ::FindWindow(_T("XLMAIN"), NULL);
if(NULL != hWnd)
{
if(!...