none
Excel Vsto create new instance of excel workbook windows RRS feed

  • Question

  • Hi all

    I need help on following code

     File.WriteAllBytes(filePath, ProjectDemo.Properties.Resources.XXX);

     oWB = app.Workbooks.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                         Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

    This code open new window in excel application which i do not want. it should open in the same window.

    Friday, March 29, 2013 3:38 PM

Answers

  • Which version of Excel?

    Please note that the "pseudo-MDI" interface has been the default for Office programs since a number of versions. By default, every file will open in a separate window, but the instance of the Office application will remain the same (check in the Task Manager).

    Up until Office 2013, it was possible to set an option to allow Excel workbooks to all open in the same main, application window. But from 2013 on this is no longer possible.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Rahul_SKD Tuesday, April 2, 2013 11:17 AM
    Saturday, March 30, 2013 6:00 AM
    Moderator
  • Hi Raul

    It will not be possible to open multiple Excel workbooks in a single application window in Excel 2013 - the functionality has been removed.

    However, in principle all the workbooks you open using app.Workbooks.Open should be running in the same instance, just separate windows. So they should all be available via app.Workbooks[index].

    If your problem is that your users aren't happy because things are different, I'm afraid they'll have to get used to working in the new environment, or not upgrade.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Rahul_SKD Tuesday, April 2, 2013 11:17 AM
    Tuesday, April 2, 2013 9:59 AM
    Moderator

All replies

  • Which version of Excel?

    Please note that the "pseudo-MDI" interface has been the default for Office programs since a number of versions. By default, every file will open in a separate window, but the instance of the Office application will remain the same (check in the Task Manager).

    Up until Office 2013, it was possible to set an option to allow Excel workbooks to all open in the same main, application window. But from 2013 on this is no longer possible.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Rahul_SKD Tuesday, April 2, 2013 11:17 AM
    Saturday, March 30, 2013 6:00 AM
    Moderator
  • Thanks For Reply,

    I am using office 2013,

    earlier i was using office 2010, when i updated it to 2013 i got this issue,

    So i there any option so that i can make newly started instance as active using C# code.


    • Edited by Rahul_SKD Monday, April 1, 2013 8:04 PM
    • Marked as answer by Rahul_SKD Tuesday, April 2, 2013 11:17 AM
    • Unmarked as answer by Rahul_SKD Tuesday, April 2, 2013 11:17 AM
    Monday, April 1, 2013 8:03 PM
  • Not sure what you are asking exactly but you can make the just opened workbook 'Active' and be able to continue to perform actions on the activated Workbook/Worksheet.

    oWB.Activate
    Worksheet oWS = app.ActiveWorkbook.ActiveSheet
    oWS.Range["A1"].Value2 = "Bla"

    What you'll see is that the "Bla" will be targeted into Cell A1 from the just opened (and activated) Workbook.

    So be sure you keep in mind what your -active- Workbook/Worksheet is when you are working with multiple Workbooks and Worksheets.

    Maarten


    Software Engineer * MVP-Visual Developer-VSTO



    Monday, April 1, 2013 9:33 PM
    Moderator
  • Hi Raul

    It will not be possible to open multiple Excel workbooks in a single application window in Excel 2013 - the functionality has been removed.

    However, in principle all the workbooks you open using app.Workbooks.Open should be running in the same instance, just separate windows. So they should all be available via app.Workbooks[index].

    If your problem is that your users aren't happy because things are different, I'm afraid they'll have to get used to working in the new environment, or not upgrade.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Rahul_SKD Tuesday, April 2, 2013 11:17 AM
    Tuesday, April 2, 2013 9:59 AM
    Moderator
  • Thanks.

    Now i am able to show window  only which i required I am using following code for closing unwanted window.

    app.Workbooks[1].Close();

    but i have question here when it open new window then Workbooks.count() must be 2 but it show 1 i did not understood why it showing me 2 because i found it show 2 window "Book1" and "Account"

    And Workbooks[1] refers "Book1" window

    I am just curious to know Why count 1 not 2

    Thanks

    Tuesday, April 2, 2013 11:14 AM
  • Hi Rahul

    I'd need to know a lot more about how your project is designed to work and see the code involved. Possibly, I'd need enough information in order to test it at my end and try to reproduce your scenario.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, April 2, 2013 3:23 PM
    Moderator