none
CommandBars.FindControl(MsoControlType.msoControlButton, 436, null, null) dosen't open Chart Wizard RRS feed

  • Question

  • Hi everybody,

    I'm developping an add-in for excel 2010 and 2013.

    I want to create a pivotChart using c#. So I use the following code to open excel chartWizard:

    ExcelApp.CommandBars.FindControl(MsoControlType.msoControlButton, 436, null, null).Execute();

    This code is working fine under excel 2010, but it dosen't work with excel 2013.

    I am using the version 12.0.0.0 of Microsoft.Office.Interop.Excel.dll.

    So is there a problem with my dll file version or there is a specific id number for excel 2013 which i must use instead of 436 to launch the chart wizard?

    Can anyone help me please?

    Thank you.

    Monday, June 16, 2014 9:20 AM

Answers

  • Hello;

    Thank you both for your answers.

    The idMso 436 does not work with  excel 2013 even if i had select a range as a datasource. On the contrary I used the IdMso 12248 which resolved my problem.

    Now the following code open the chartwizard for me in excel 2013:

    ExcelApp.CommandBars.FindControl(MsoControlType.msoControlButton,12248, null, null).Execute();

    • Marked as answer by saidOuarrich Tuesday, June 17, 2014 2:01 PM
    Tuesday, June 17, 2014 2:00 PM

All replies

  • Hello,

    Command bars are marked as obsolete and not supported any longer. Instead, you need to specify the idMso value which you can find in the Office 2013 Help Files: Office Fluent User Interface Control Identifiers  . The Fluent UI is used nowadays. You can read more about the new UI in the following series of articles in MSDN:

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

    Monday, June 16, 2014 11:37 AM
  • Hi,

    Welcome to MSDN forum.

    According to my investigation, the ribbon id is both 436 in Excel 2010 and Excel 2013.

    In Excel 2010, if I ran the code you provided, I would find:

    But in Excel 2013, I would find:

    The code is correct since the feature of "insert chart" has been changed in Excel 2013. If you click the ribbon named "More Scatter Charts", you would get the same result. If you want to insert a chart in Excel 2013, you need to select a range as datasource first.

    Since the feature in Excel has been changed, you need to use Application.Version Property (Excel)to determine version of Excel.

    It might be like this:

    if (ExcelApp.Version == "12.0")
                {
                    ExcelApp.CommandBars.FindControl(MsoControlType.msoControlButton, 436, null, null).Execute();
                }
                else if (ExcelApp.Version == "15.0")
                {
                    ExcelApp.ActiveSheet.Range("A1:B4").select();
                    ExcelApp.CommandBars.FindControl(MsoControlType.msoControlButton, 436, null, null).Execute();
                }
    Hope this helps.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 17, 2014 3:38 AM
    Moderator
  • Hello;

    Thank you both for your answers.

    The idMso 436 does not work with  excel 2013 even if i had select a range as a datasource. On the contrary I used the IdMso 12248 which resolved my problem.

    Now the following code open the chartwizard for me in excel 2013:

    ExcelApp.CommandBars.FindControl(MsoControlType.msoControlButton,12248, null, null).Execute();

    • Marked as answer by saidOuarrich Tuesday, June 17, 2014 2:01 PM
    Tuesday, June 17, 2014 2:00 PM