0

I have created a C# Winforms app and on Windows 7, as I populate my excel sheet (via Microsoft Outlook 15.0 Object Library), the sheet opens and you can see it being populated, and then it closes as I programmatically close the object. I do not what the excel sheet to appear as it's being populated.

The excel sheet does not appear when I run it in visual studio on my windows 2008 server. It only appears on Windows 7 (64 bit). I've tried the following (and here is my code to create the objects. I have excel 2013 64-bit on the Windows 7 (where the sheet shows) box and the server(where the excel sheet does not show). Any ideas?(I tried all the solutions here: Hide Excel 2013 while programmatic change a workbook) with no luck :

        using Excel = Microsoft.Office.Interop.Excel;


        Excel.Application xlApp;
        Excel.Workbook xlWorkBook;
        Excel.Worksheet xlWorkSheet;
        //Excel.Worksheet xlWorkSheet2;
        object misValue = System.Reflection.Missing.Value;


        xlApp = new Excel.Application();
        try
        {
            // This was added to try to hide, but no dice
            // Must be surrounded by try catch to work.
            // http://naimishpandya.wordpress.com/2010/12/31/hide-power-point-application-window-in-net-office-automation/
            xlApp.Visible = false;
            xlApp.DisplayAlerts = false;
        }
        catch (Exception )
        {
            //Console.WriteLine("-------Error hiding the application-------");
            //Console.WriteLine("Occured error might be: " + e.StackTrace);
        }
        xlWorkBook = xlApp.Workbooks.Add(misValue);
        xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
Danimal111
  • 1,976
  • 25
  • 31

0 Answers0