Create a context menu in Word

K

Kaustav

Hello,

I created a shared add-in for Word (Word 2003) where in I added a custom
toolbar with a couple of buttons in it. These buttons brings up some custom
windows forms from my application. Is it possible to show a context menu on
the right click event of any word document (something on the lines of menus
like Fonts/Paragraph/Synonyms) to call these custom forms (perform the same
button click event as its available from the toolbar)? If yes, how or any
pointers will be much appreciated. I am developing this addin with .NET v1.1,
Word 2003.
 
J

Jezebel

The menus part of this is easy -- you can create these to your heart's
content. The tricky bit is knowing when to fire them, because Word doesn't
expose its click events.

The simpler approach is to add your own options to the existing context
menus. The challenge here is that there are *lots* of them. To see what
you're dealing with --

- open Word
- right-click any toolbar and select Customise
- check 'Shortcut menus' on the Toolbars tab

This displays the special shortcut menus toolbar: the options on this
toolbar drop down to show you the full sets of context menus that Word fires
automatically. You can add your own options to any or all of these.

And if you're thinking to the future, bear in mind that W2007 handles menus
and toolbars differently.
 
C

Cindy M.

Hi =?Utf-8?B?S2F1c3Rhdg==?=,
I created a shared add-in for Word (Word 2003) where in I added a custom
toolbar with a couple of buttons in it. These buttons brings up some custom
windows forms from my application. Is it possible to show a context menu on
the right click event of any word document (something on the lines of menus
like Fonts/Paragraph/Synonyms) to call these custom forms (perform the same
button click event as its available from the toolbar)? If yes, how or any
pointers will be much appreciated. I am developing this addin with .NET v1.1,
Word 2003.
You can sink the WindowBeforeRightClick application event. Figure out where the
SEL(ection - parameter passed with the event) is, then, if appropriate, alter
the commandbar that will be triggered accordingly.

But as Jezebel says, it's probably just as simple to modify these commandbars as
you do any other ones. Just be careful about the CustomizationContext (as always
with Word).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Cindy M.

Hi Jezebel,
And if you're thinking to the future, bear in mind that W2007 handles menus
and toolbars differently.
Except the right-click context menus. Those are still handled the same way...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top