locked
Intercept right-click on a picture in Word RRS feed

  • Question

  • Hi,

    Is it possible to modify the context menu shown in Word when a picture is clicked (e.g. to add a new menu item). If not is it possible to intercept the right-click on a picture and show a custom menu.

    So far I was able to modify the context menu shown when the user clicks on text. I can also intercept the right-click on a text. However, the right-click event is not fired when the user clicks on a picture. Moreover, I was unable to find the context menu show when a picture is clicked. I looked at all Application.CommandBars but was unable to find that specific menu.

    If the above is not possible can this done in an add-in?

    Thanks a lot,
    Jecho Jekov

    Thursday, September 15, 2011 3:40 PM

Answers

  • yes, inserted a control "Image" into a Word document then you must use the control's property "Picture" to load a picture
     
    --
    isabelle
     Le 2011-09-16 04:29, Jecho Jekov a écrit :
    > Hi Isabelle,
    >
    > Thanks for the reply.
    >
    > Sorry if I wasn't clear in my post. It is not about a user form in VBA. It is about a picture inserted into a Word document. I want to be able to modify the context menu shown when a user right-clicks on a picture.
    >
    > Regards,
    > Jecho Jekov
    >
     
    • Marked as answer by Jecho Jekov Friday, September 16, 2011 3:22 PM
    Friday, September 16, 2011 11:51 AM
  • sorry, i'm working with XL2002, i think there is certainly a particularity of Word 2007.
     
    on the following link there is an example of a file stored on the version XL2002 can you try it?
     
    meanwhile i will search for information on CommandBars for xl2007
     
    --
    isabelle
     
    • Marked as answer by Jecho Jekov Saturday, September 17, 2011 7:26 PM
    Saturday, September 17, 2011 12:44 AM
  • glad to help, and also that you can be using a document XL2002
    look at the conclusions of Ron de Bruin on the bottom of the following page:
     
    --
    isabelle
     
    Le 2011-09-17 15:26, Jecho Jekov a écrit :
    > Hi Isabelle,
    >
    > Thank you very much for your response and for the example. It actually works in Word 2007 and I found the problem. Images in Word 2003 and earlier format (.doc) are treated differently from images in Word 2007 and later format (.docx) and different context menus are shown when you right click on an image. The "Inline Picture" menu is shown only for images in .doc format. So far I was unable to find the context menu shown for images in .docx format even by using your script for command bars. Some
    > of the menu items appearing in that menu do not show up in Excel for any command bar at all. It's a mystery for me :-)
    >
    > The .doc format is sufficient for me so my problem is solved.
    >
    > Thank you very much for your help.
    >
    > Regards,
    > Jecho Jekov
    >
     
    • Marked as answer by Jecho Jekov Sunday, September 18, 2011 6:59 AM
    Saturday, September 17, 2011 11:22 PM

All replies

  • hi Jecho Jekov,
     
    inserting your image in a control "Image" from the Control Toolbox Toolbar and try again
     
    --
    isabelle
     
    Le 2011-09-15 11:40, Jecho Jekov a écrit :
    > Hi,
    >
    > Is it possible to modify the context menu shown in Word when a picture is clicked (e.g. to add a new menu item). If not is it possible to intercept the right-click on a picture and show a custom menu.
    >
    > So far I was able to modify the context menu shown when the user clicks on text. I can also intercept the right-click on a text. However, the right-click event is not fired when the user clicks on a picture. Moreover, I was unable to find the context menu show when a picture is clicked. I looked at all *Application.CommandBars* but was unable to find that specific menu.
    >
    > If the above is not possible can this done in an add-in?
    >
    > Thanks a lot,
    > Jecho Jekov
    >
     
    Thursday, September 15, 2011 10:28 PM
  • Hi Isabelle,

    Thanks for the reply.

    Sorry if I wasn't clear in my post. It is not about a user form in VBA. It is about a picture inserted into a Word document. I want to be able to modify the context menu shown when a user right-clicks on a picture.

    Regards,
    Jecho Jekov

    Friday, September 16, 2011 8:29 AM
  • yes, inserted a control "Image" into a Word document then you must use the control's property "Picture" to load a picture
     
    --
    isabelle
     Le 2011-09-16 04:29, Jecho Jekov a écrit :
    > Hi Isabelle,
    >
    > Thanks for the reply.
    >
    > Sorry if I wasn't clear in my post. It is not about a user form in VBA. It is about a picture inserted into a Word document. I want to be able to modify the context menu shown when a user right-clicks on a picture.
    >
    > Regards,
    > Jecho Jekov
    >
     
    • Marked as answer by Jecho Jekov Friday, September 16, 2011 3:22 PM
    Friday, September 16, 2011 11:51 AM
  • also to modify the context menu shown in Word when a picture is clicked,
     
    Sub Add_Commmand_to_Inline_Picture_menu()
    With Application.CommandBars("Inline Picture").Controls.Add(msoControlButton)
        .Caption = "Say Hello"
        .BeginGroup = True
        .FaceId = 252
        .OnAction = "Hello"
    End With
    End Sub
     
    Sub Hello()
    MsgBox "Hello"
    End Sub
     
    Sub Reset_Inline_Picture_menu()
    Application.CommandBars("Inline Picture").Reset
    End Sub
     
    --
    isabelle
     
     
    Friday, September 16, 2011 1:24 PM
  • This file contains macros for all CommandBars name for Word and Excel
     
     
    --
    isabelle
     
     
    Friday, September 16, 2011 1:58 PM
  • Hi Isabelle,

    Thank you very much for your response. I really appreciate it.

    Your suggestion to insert an "Image" control worked. Though I prefer to just add a picture it worked.

    I've already tried to add a menu item to Application.CommandBars("Inline Picture"). However, the menu item simply does not appear in the menu. I can see the menu item in "Watches". Its visibility is set to visible and it is enabled but it does not show up in the menu. When I add a menu item to the Application.CommandBars("Text") menu there is no such problem. Do you have any idea why? I use Word 2007.

    Your macro showing all command bars is great. Thank you.

    Regards,
    Jecho Jekov

    Friday, September 16, 2011 3:47 PM
  • sorry, i'm working with XL2002, i think there is certainly a particularity of Word 2007.
     
    on the following link there is an example of a file stored on the version XL2002 can you try it?
     
    meanwhile i will search for information on CommandBars for xl2007
     
    --
    isabelle
     
    • Marked as answer by Jecho Jekov Saturday, September 17, 2011 7:26 PM
    Saturday, September 17, 2011 12:44 AM
  • Hi Isabelle,

    Thank you very much for your response and for the example. It actually works in Word 2007 and I found the problem. Images in Word 2003 and earlier format (.doc) are treated differently from images in Word 2007 and later format (.docx) and different context menus are shown when you right click on an image. The "Inline Picture" menu is shown only for images in .doc format. So far I was unable to find the context menu shown for images in .docx format even by using your script for command bars. Some of the menu items appearing in that menu do not show up in Excel for any command bar at all. It's a mystery for me :-)

    The .doc format is sufficient for me so my problem is solved.

    Thank you very much for your help.

    Regards,
    Jecho Jekov

    Saturday, September 17, 2011 7:26 PM
  • glad to help, and also that you can be using a document XL2002
    look at the conclusions of Ron de Bruin on the bottom of the following page:
     
    --
    isabelle
     
    Le 2011-09-17 15:26, Jecho Jekov a écrit :
    > Hi Isabelle,
    >
    > Thank you very much for your response and for the example. It actually works in Word 2007 and I found the problem. Images in Word 2003 and earlier format (.doc) are treated differently from images in Word 2007 and later format (.docx) and different context menus are shown when you right click on an image. The "Inline Picture" menu is shown only for images in .doc format. So far I was unable to find the context menu shown for images in .docx format even by using your script for command bars. Some
    > of the menu items appearing in that menu do not show up in Excel for any command bar at all. It's a mystery for me :-)
    >
    > The .doc format is sufficient for me so my problem is solved.
    >
    > Thank you very much for your help.
    >
    > Regards,
    > Jecho Jekov
    >
     
    • Marked as answer by Jecho Jekov Sunday, September 18, 2011 6:59 AM
    Saturday, September 17, 2011 11:22 PM
  • Hi Isabelle,

    Thank you for the link. Very useful to know :-)

    Regards,
    Jecho Jekov

    Sunday, September 18, 2011 6:59 AM