Adding a button to a Word shortcut menu

K

Khouri

What I want to do:
Add a button to the shortcut menu that appears when a user right-clicks on a
piece of text.
Compatible with Word 2000 and up
Using Visual Basic .Net

So far I've tried using a shared add-in project and tried a few things, but
I'm really stuck and don't know for sure if it's even possible what I want to
do. Can someone point me in the right direction here?
 
K

Khouri

Sorry for the multiple posts, I kept getting errors and not seeing my posts
appear, until now.
 
K

karina thomas

Do you need to do this through Visual Basic .Net, or can you do it directly
using the Word interface? The item you are trying to edit is called the Short
Cut Menu and can be done directly in Word by choosing Tools, Customize, then
selecting the Shortcut Menus checkbox on the Toolbar tab. Then you can click
the appropriate short cut menu on the toolbar that pops up and customize it
in whatever way is appropriate. This is then saved to whatever template you
want. And if you like, you can make this a Startup template (by virtue of
saving it in the appropriate location) which will be automatically available
to the user when they start Word. Generally it is preferable to program
toolbars directly through the Word interface, rather than at run time.

However, if the above is not an option, and it must be programmed at
run-time, then you are looking at programming using the CommandBars object
(VBA...all I'm familiar with), specifically, the shortcut menus are Popup
Controls. When you create (.Add) a new CommandBar the position needs to be
msoBarPopup to indicate that it is a Shortcut Menu. Otherwise, all the code
is pretty much just like dealing with any other type of toolbar or menu bar.
If you need to edit an existing ShortCut menu, you will need to identify the
name of the CommandBar, then you can use the .ID property to specify the
exact menu to edit.

In order to really help with any code though, I'd need to know specifically
what you are trying to accomplish.

Cheers,
Karina
 
K

Khouri

Thx for your help. Though VB.Net seems best to me, since the rest of the
product this is for is also implemented in VB.Net. I've been able to add
items to the Text shortcut menu in code now, through a shared add-in, but am
still a bit lost when it comes to Word programming. If you think VBA can do a
better job at this, I can switch to that.
What I'm trying to do is: when a text is selected and a user right-clicks on
said text, in the menu that appears (I found out it's called "Text" and am
currecntly using that name to track it down, but ID might be better, indeed)
I want to add a button that passes that text to another application (I'm
thinking some neato form of IPC, but that's not really the Word bit). This
needs to be available at all times, not just through a special template or
after clicking a special button or something.
What I've noticed so far is:
- when starting the application, I can't show msgboxes
- when starting or shutting down the application, the Text menu does not exist
- my add-in only seems to run once
These are more VB.Net add-in issues although I'm still looking for a way to
add a picture (if possible) in front of my new-fangled button and how to tie
events into it (actually, my button is still an empty field atm).

Marco
 

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