CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2014
    Posts
    2

    excel automation - window doesn't come to the foreground in Windows Server 2008

    We have a C++ 5.0 app that does something like this:

    Creates the excel dispatch, exports the data, etc...
    ...
    then calls these functions:

    xlsApp.SetDisplayAlerts(TRUE);
    xlsApp.SetVisible(TRUE);
    xlsApp.SetUserControl(TRUE);

    This has always worked to display the excel spreadsheet in the foreground, most recently on Windows Server 2003.

    Now, testing on Windows Server 2008, the excel spreadsheet is created, but in the background.

    Any suggestions on how to force it to the foreground?

    Thanks much!

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: excel automation - window doesn't come to the foreground in Windows Server 2008

    I would immediately consider using a workaround, such as using FindWindow() and SetForegroundWindow().
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Feb 2014
    Posts
    2

    Re: excel automation - window doesn't come to the foreground in Windows Server 2008

    Thank you so much for the tip! A very simple workaround, once I figured out to use "XLMAIN" for the application parameter in FindWindow().

    HWND xlsHWnd = FindWindow(_T("XLMAIN"), NULL);
    SetForegroundWindow(xlsHWnd);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured