Visual Studio Developer Center > Visual Studio Forums > Visual Studio Tools for Office > Get currently visible context menu in Word 2007
Ask a questionAsk a question
 

AnswerGet currently visible context menu in Word 2007

  • Thursday, November 05, 2009 7:21 AMJagrut Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi all,

    In Word 2007, how can I get reference of context menu that appears on right-clicking selected text? In Word 2003, I used following logic:
    1. Iterate all CommandBar of type msoBarTypePopup
    2. Find one that is visible using Visible property of CommandBar object (There is always one popup-menu visible!)

    In Word 2007, Visible property of CommandBar object of type msoBarTypePopup is always false even if that pop-up is actually visible in Word document.

    My guess is that this may be because of the Formatting context menu that appears besides actual context menu on right-clicking selected text. I would also like to know whether displaying Formatting context menu can be suppressed on right-clicking? I know this is possible when text is selected.

    Thank you all.
    Jagrut

Answers

  • Thursday, November 05, 2009 10:35 AMCindy MeisterMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Jagrut

    The "mini-toolbar" can be deactivated via Word Options/Popular/Show Mini Toolbar on Selection. If you want to do this programmatically, record a macro when changing the setting and that should give you the syntax.

    FWIW, if that doesn't solve the issue, then I suspect there's nothing you can do about it, short of possibly using the Windows API. The Office 2007 applications are in a transition phase between toolbars and the ribbon. In Word you can still address context menus via the CommandBars object model, but this doesn't hold for all Office 2007 apps. In Office 2010 the context menues are moving to the Ribbon UI. So I suspect the problem might be linked with this "transition phase": not all the functionality is still available.
    Cindy Meister, VSTO/Word MVP
  • Thursday, November 05, 2009 12:06 PMJagrut Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hey Cindy,

    Thank you for the reply.

    As I mentioned earlier deactivating "mini-toolbar" option only hides it on text selection. On right-clicking, "mini-toolbar" still appears. So this option is not helpful here.

    I am using CommandBars object model to access the context menu. I wonder what heavy-lifting logic Visible property might be having that it was not possible to set it to true when menu becomes visible??? Seems I have to live with this bug if Win32 API doesn't help!

    BTW, nice to know beforehand that my context menu handling 'may' not work in Office 2010.

    Thank you once again.


    Jagrut

All Replies

  • Thursday, November 05, 2009 10:35 AMCindy MeisterMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Jagrut

    The "mini-toolbar" can be deactivated via Word Options/Popular/Show Mini Toolbar on Selection. If you want to do this programmatically, record a macro when changing the setting and that should give you the syntax.

    FWIW, if that doesn't solve the issue, then I suspect there's nothing you can do about it, short of possibly using the Windows API. The Office 2007 applications are in a transition phase between toolbars and the ribbon. In Word you can still address context menus via the CommandBars object model, but this doesn't hold for all Office 2007 apps. In Office 2010 the context menues are moving to the Ribbon UI. So I suspect the problem might be linked with this "transition phase": not all the functionality is still available.
    Cindy Meister, VSTO/Word MVP
  • Thursday, November 05, 2009 12:06 PMJagrut Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hey Cindy,

    Thank you for the reply.

    As I mentioned earlier deactivating "mini-toolbar" option only hides it on text selection. On right-clicking, "mini-toolbar" still appears. So this option is not helpful here.

    I am using CommandBars object model to access the context menu. I wonder what heavy-lifting logic Visible property might be having that it was not possible to set it to true when menu becomes visible??? Seems I have to live with this bug if Win32 API doesn't help!

    BTW, nice to know beforehand that my context menu handling 'may' not work in Office 2010.

    Thank you once again.


    Jagrut