none
Unable to launch application in background RRS feed

  • Question

  • I'm using Visual Studio 2013 to update a program for compatibility with Office 2016. The program uses Excel to generate various reports based on values in an Access database.  When upgraded to 2016, it calls an Excel window to the front every time a new instance of Excel is started. Even with the application's ScreenUpdating and Visible properties set to False, it briefly pops up the window before making it invisible. I need to stop even that brief pop up. How can I do that?

    
    
    
    
    • Moved by Oscar_Wu Tuesday, March 21, 2017 2:07 AM related to C#
    • Moved by CoolDadTx Tuesday, March 21, 2017 2:12 PM Office related
    Monday, March 20, 2017 5:06 PM

All replies

  • Hi Colby H,

    This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Your issue is related to C# develop, I will move this thread to corresponding forum for a professional answer.

    Sincerely,

    Oscar


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 21, 2017 2:07 AM
  • Hi Colby H,

    If you have the following line in your code which might causing your excel file to pop up in to front. You could comment out this line.

    Window.Activate method

    Also could you please provide a code snippet this will help us to give you appropriate soulution.

    app.ActiveWindow.Activate();


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Tuesday, March 21, 2017 1:04 PM
  • The code is below.  What happens is that if I set oExcel.Visible to false prior to creating a workbook, the code has no effect.  If I set it to false after calling a new workbook, it will make it invisible but only after calling it to full screen, creating a strobe effect when several workbooks/worksheets are accessed in the same command.  If I set oExcel.WindowState to minimized, it crashes as soon as it attempts to merge cells.

            Dim oExcel As Microsoft.Office.Interop.Excel.Application
            Dim oBook As Microsoft.Office.Interop.Excel.Workbook
            Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet
            Dim misValue As Object = System.Reflection.Missing.Value

            oExcel = New Microsoft.Office.Interop.Excel.Application
            oBook = oExcel.Workbooks.Add(misValue)

            oExcel.Visible = False
            oExcel.ScreenUpdating = False

    Tuesday, March 21, 2017 2:37 PM
  • Try to set Visible and ScreenUpdating properties first:

    Dim oExcel As Microsoft.Office.Interop.Excel.Application
             Dim oBook As Microsoft.Office.Interop.Excel.Workbook
             Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet
             Dim misValue As Object = System.Reflection.Missing.Value
    
    
            oExcel = New Microsoft.Office.Interop.Excel.Application
    
            oExcel.Visible = False
            oExcel.ScreenUpdating = False
    
            oBook = oExcel.Workbooks.Add(misValue)
    


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, March 21, 2017 3:24 PM
  • Unfortunately that's the problem I've run into.  If I set the .visible property to false at that point (before calling the workbook), the program acts as though it can't see that line of code.  Excel still opens as though .visible is true.  The only way I've managed to hide the workbook is to Add first and then set .visible to false after the workbook is called.

    Any other suggestions?

    Thanks!

    Tuesday, March 21, 2017 6:50 PM
  • Hello Colby,

    I only test the code snippet and the results show the position of line oExcel.Visible = False would not effect the performance. I suggest you create a new sub to test the code only to check if the issue still exists. Then try to comment out parts by parts in your original project to check which line causes the issue.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 22, 2017 8:02 AM
    Moderator