Re: VBA Word: How to customize a right click menu bar(shortcut menu)? by Jezebel
Jezebel
Fri Oct 27 21:32:53 CDT 2006
First, it's not "the" right-click menu -- there are lots of them, depending
on the selection at the time. To see the list, right-click any existing
toolbar, select Customize, and check 'Shortcut menus' on the Toolbars tab.
The Shortcut menus toolbar, visible only when customizing, gives you access
to the shortcut menus in order to customize them manually.
Rather than adding and removing options each time, it might be easier to add
all the options when your code loads (perhaps when you initialize your class
module), then show/hide the ones you want.
You can retain persistent references to the options that you add --
set mnuAdd = CommandBars.....Add(...)
You can check if a menu contains a given options by examining its Controls
collection. When you add an option you can set its Tag property; you can
then use CommandBars.FindControl(Tag:=...) to retrieve it.
Note that menus are part of Office, not part of Word. They are defined in
the Office library. Menus and toolbars are the same thing. The difference is
only whether the options are shown as trext or as icons.
"sharon3874" <sharon_job88@yahoo.com> wrote in message
news:1161995618.154738.119930@e3g2000cwe.googlegroups.com...
>
> Thank you very much!!! It works!!!
>
> I have another question. If it is "A", I want to add a menu item "add"
> to the end of the right click menu bar, if it is "B", I want to add a
> menu item "edit" and "remove" to the end of the right click menu bar.
> it seems like if I right click on "A", then "B", I will have all menu
> items("add", "edit" and "remove"), but I only want "edit" and "remove".
> Do I need to delete "add"? is there a better way? Also, if I need to
> delete "add", how do I check if "add" menu item exists already?
>
> Thanks again
>