none
Globals.ThisAddIn.Application.CommandBars.FindControl(Control Id).Execute() throwing exception in Office 2010 RRS feed

  • Question

  • Hi,
    I am developing VSTO Add-Ins. Through this add-in i am trying to add a Rectangle and Line callout in powerpoint.
    The code for Rectangle is:
    Globals.ThisAddIn.Application.CommandBars.FindControl(Type.Missing, ((object)1111), Type.Missing, Type.Missing).Execute();
    The code for line callout is:
    Globals.ThisAddIn.Application.CommandBars.FindControl(Type.Missing, ((object)1177), Type.Missing, Type.Missing).Execute();
    The add-in works fine in Office 2007 environment. However when run in Office 2010 environment it gives "Error HRESULT E_FAIL has been returned from a call to a COM component."
    On analysing this, i think the above control ids might be missing from the Office 2010. Can you please specify what is the control ids for rectangle and line call out in office 2010?

    • Edited by Saheli Basu Tuesday, March 6, 2012 12:09 PM
    Tuesday, March 6, 2012 12:03 PM

Answers

All replies

  • Hi Sabeli,

    Yes, I can repro the issue, it seems to be a bug for me. But I'm not sure about this, I need to consult some senior engineers to confirm this and bring back a workaround.

    Please be patient before we can inform you with some valuable suggestions.

    Good day,


    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, March 7, 2012 8:51 AM
    Moderator
  • Hi,

    Please modify your code as below and retry:

    Globals.ThisAddIn.Application.CommandBars.FindControl(Type.Missing, ((object)1111), Type.Missing, Type.Missing).accDoDefaultAction(0);

    This call is basd on Microsoft Active Accessibility against the command bar. Could this fix the issue?

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Wednesday, March 7, 2012 3:32 PM
    Moderator
  • Please ignore the above suggestion, I tested and verified that it runs into same exception. In another idea, I located the Rectangle icon command with Inspect.exe, then execute default action and it works, I realized that this command bar function needs user interaction, user have to specify where to start the drawing.

    Anyway, I'll try to get other experienced people help on this question.

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Thursday, March 8, 2012 9:01 AM
    Moderator
  • Hi,

    in PPT2010 you can try this instead:

    Globals.ThisAddIn.Application.CommandBars.ExecuteMso("ShapeRectangle");

    Globals.ThisAddIn.Application.CommandBars.ExecuteMso("ShapeStraightConnector");

    the id 1117 =

    ShapeIsoscelesTriangle

    You can find the msoIds here:

    2003+2007
    http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=3582

    2010:

    http://www.microsoft.com/download/en/details.aspx?id=6627


    Helmut Obertanner [http://www.obertanner.de] [http://www.outlooksharp.de]


    Thursday, March 8, 2012 5:03 PM
    Answerer
  • Hi Sabeli,

    The Office 2010 control IDs are in the Office 2010 Help Files:
    Office Fluent User Interface Control Identifiers file – a very extensive list.
    Click the second link below to get that download.  You can filter for the appropriate control.

    Microsoft Download Center
    http://www.microsoft.com/download/en/search.aspx?q=control%20ids

    The top two downloads include 2007 Office System Document:
    Lists of Control IDs
    and
    Office 2010 Help Files: Office Fluent User Interface Control Identifiers
    http://www.microsoft.com/download/en/details.aspx?id=6627

    Please click the “Mark as Answer” button if this answers
    your need.

    Regards,
    Chris Jensen
    Senior Technical Support Lead





    Chris Jensen

    Thursday, March 8, 2012 9:00 PM
    Moderator
  • Awesome ! 

    Globals.ThisAddIn.Application.CommandBars.ExecuteMso("ShapeRectangle"); works to draw rectangle. However, I serached the control name for Line with no luck.  It appears that draw line icon command doesn't provide such control name.


    Forrest Guo | MSDN Community Support | Feedback to us

    Friday, March 9, 2012 2:44 AM
    Moderator
  • Hi Forrest,

    some cool Developer gave it the name: ShapeStraightConnector

    Globals

    .ThisAddIn.Application.CommandBars.ExecuteMso("ShapeStraightConnector");

    Should do the Trick!

    Greets - Helmut


    Helmut Obertanner [http://www.obertanner.de] [http://www.outlooksharp.de]

    Friday, March 9, 2012 7:34 AM
    Answerer
  • Frankly speaking, the control name is not intuitive and hard to be found. 

    Thank you, this is impressive.

    Best Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

    Friday, March 9, 2012 7:43 AM
    Moderator
  • Hi Helmut,

    Thanks for your suggestion!!

    The "ShapeRectangle" option for Rectangle worked perfectly for me. However the second control is not exactly what i am looking for.

    More precisely i am looking for the control name for "Line Callout 2". The exact navigation path for that control in PPT 2010 is: Insert|Shapes|Callouts|Line Callout 2

    Can you please suggest?

    Thanks in advance.

    Saheli.

    Friday, March 9, 2012 11:36 AM
  • Hi Sheli,

    sorry - I think your out of luck.
    As far as I know there is no MsoId for the Gallery Controls.

    Your best Option would be: "ShapeRoundedRectangularCallout" That's the only one I can get working.

    Greets - Helmut


    Helmut Obertanner [http://www.obertanner.de] [http://www.outlooksharp.de]

    Friday, March 9, 2012 1:35 PM
    Answerer