none
FindControls question (VBA vs. C#) RRS feed

  • Question

  • I am trying to either hide or redirect the "Reply to Comment" command that Word displays when a user right clicks inside a comment.

    I am able to get this to work in VBA:

    Set myControls = WordApp.CommandBars.FindControls _

    (Type:=msoControlButton, ID:=854)

    However,  when I try this in C#, the control button is not found:

    var myControl = Wd.WordApp.CommandBars.FindControl

    (MsoControlType.msoControlButton, Id: 854);

    Can anyone tell me what I'm doing wrong? 

    (The command I am trying to find is ReplyToAnnotation in the "Customize the Ribbon" window in Word. 

    Thanks!


    • Edited by MattP34 Monday, April 24, 2017 9:37 PM
    Monday, April 24, 2017 8:58 PM

All replies

  • Hi,
    You used FindControls in VBA code but FindControl in C#. Besides, I didn't find any built-in control's id is 854 neither in Word 2007,2010,2013 or 2016.
    Here is my code using FindControls in c#.
    Word.Application app = Globals.ThisAddIn.Application;
    CommandBarControls myControls;       
     myControls = app.CommandBars.FindControls(Id:3);

    Best 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.

    Thursday, April 27, 2017 4:59 AM
    Moderator