How add new item into Context Menu for Right Mouse Click for Word2007?

A

avkokin

Hello.
I know how to add new item into context menu for right Mouse click in
Word 2003. But how can I did this for Word 2007? Without VBA? This is
impossible?
Thank you.
 
S

Stefan Blom

Your assumption is correct: it cannot be done without VBA.

--
Stefan Blom
Microsoft Word MVP


in message
news:7810c9a1-f1a1-4338-8467-f28de87d3b49@s19g2000prg.googlegroups.com...
 
S

Stefan Blom

It seems you are one step ahead of me... :)

--
Stefan Blom
Microsoft Word MVP


in message
 
Joined
Apr 18, 2008
Messages
1
Reaction score
0
customization of right click context menu is possible with word 2007. Following is the code

Microsoft.Office.Interop.Word.Application app;
app = (Microsoft.Office.Interop.Word.Application)applicationObject;
CommandBar cellbar = app.CommandBars["Text"];
CommandBarButton button = (CommandBarButton)cellbar.FindControl(MsoControlType.msoControlButton, 0, "MYRIGHTCLICKMENU", Missing.Value, Missing.Value);
if (button == null)
{
// add the button
button = (CommandBarButton)cellbar.Controls.Add(MsoControlType.msoControlButton, Missing.Value, Missing.Value, cellbar.Controls.Count + 1, true);
button.Caption = "My Right Click Menu Item";
button.BeginGroup = true;
button.Tag = "MYRIGHTCLICKMENU";
button.Click += new _CommandBarButtonEvents_ClickEventHandler(button_Click);
}


//handler for the button click
private void MyButton_Click(CommandBarButton cmdBarbutton, ref bool cancel)
{
System.Windows.Forms.MessageBox.Show("MyButton was Clicked", "MyCOMAddin");
}

I hope you can get this working..

Cheers

Rajshree Dugar
 

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