none
How to show custom command bar button on right click on bullet point text? RRS feed

  • Question

  • Below some paragraph with bullet point.

    3.      Transactions with Related Parties:.

    On the same date, the Company also entered into the following agreements with companies wholly-owned by members of the Restis family:

    • The Master Agreement to purchase an aggregate of six dry bulk vessels from companies affiliated with certain members of the Restis family, for an aggregate purchase price of $404,876 including direct transaction costs plus contingent consideration.
    • A management agreement with Enterprises Shipping and Trading S.A. (“EST”), a company wholly owned by a member of the Restis family, for the provision of technical management services relating to vessels for an initial period of two years from the date of signing.

    When I right click on bullet point text e.g:-on first bullet point place crusor on Master and right click then I want shoe custom button?

    so can anyone say me the code in c# to how to do this?



    • Edited by BarunSmart Wednesday, July 11, 2012 11:47 AM
    Wednesday, July 11, 2012 11:45 AM

Answers

  • Hey Cindy

    The word Version is office2007 and this COM Add-in.

    I found the answer the name of context menu  show when right click on bullet text is "Lists".

    And to add commandbar button in C# code will be like this

    Microsoft.Office.Interop.Word.Application wdApplication;

    (Microsoft.Office.Core.CommandBarButton)wdApplication.CommandBars["Lists"].Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton, omissing, omissing, omissing, true);

    • Marked as answer by BarunSmart Thursday, July 12, 2012 7:05 AM
    • Unmarked as answer by BarunSmart Thursday, July 12, 2012 7:05 AM
    • Marked as answer by Quist ZhangModerator Tuesday, July 17, 2012 6:59 AM
    Thursday, July 12, 2012 7:01 AM

All replies

  • Hi Barun

    As with your other question: we need to know which version of Word is involved.

    For this question, we also need to know what kind of C# project you envision. Is this a VSTO add-in? A COM Add-in? Something else? Please be precise.

    In general terms, you need to work with WindowBeforeRightClick event of the Word.Application object. This event has an argument Sel that returns the Range of the current selection (where the mouse clicked) in the document. Based on that Range, you can determine the action you want (display a button).

    If you can be sure this is a simple, bulleted list (not a multi-level list where one level just happens to be a bullet), then the test required would be:
         if(Sel.Paragraphs(1).Range.ListFormat.ListType==Word.WdListType.wdListBullet)


    Cindy Meister, VSTO/Word MVP

    Wednesday, July 11, 2012 1:59 PM
    Moderator
  • Hey Cindy

    The word Version is office2007 and this COM Add-in.

    I found the answer the name of context menu  show when right click on bullet text is "Lists".

    And to add commandbar button in C# code will be like this

    Microsoft.Office.Interop.Word.Application wdApplication;

    (Microsoft.Office.Core.CommandBarButton)wdApplication.CommandBars["Lists"].Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton, omissing, omissing, omissing, true);

    • Marked as answer by BarunSmart Thursday, July 12, 2012 7:05 AM
    • Unmarked as answer by BarunSmart Thursday, July 12, 2012 7:05 AM
    • Marked as answer by Quist ZhangModerator Tuesday, July 17, 2012 6:59 AM
    Thursday, July 12, 2012 7:01 AM