Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Iam Using VS 2010 , i want to add Add right click item in ms word using vb.net.

I dont have this Event Handler

Private Sub ThisAddIn_Startup() Handles Me.Startup

End Sub 


i tried this but not working
Dim cellbar As Office.CommandBar = Doc.Application.CommandBars("Cell")
       Dim button As Office.CommandBarButton = DirectCast(cellbar.FindControl(Office.MsoControlType.msoControlButton, 0, "MYRIGHTCLICKMENU"), Office.CommandBarButton)
       If button Is Nothing Then
           ' add the button
           button = DirectCast(cellbar.Controls.Add(Office.MsoControlType.msoControlButton, , , cellbar.Controls.Count, True), Office.CommandBarButton)
           button.Caption = "Refresh"
           button.BeginGroup = True
           button.Tag = "MYRIGHTCLICKMENU"
           ' button.Click += New Office._CommandBarButtonEvents_ClickEventHandler(AddressOf MyButton_Click)
       End If


Experts,Please give me suggestions to get a solution

Thanks in advance
Posted
Updated 16-Jul-14 0:47am
v5

1 solution

C#
_CommandBarButtonEvents_ClickEventHandler eventHandler;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            try
            {
                eventHandler = new _CommandBarButtonEvents_ClickEventHandler
				(MyButton_Click);
                Word.Application applicationObject =
			Globals.ThisAddIn.Application as Word.Application;
                applicationObject.WindowBeforeRightClick +=
		new Microsoft.Office.Interop.Word.ApplicationEvents4_
		WindowBeforeRightClickEventHandler(App_WindowBeforeRightClick);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error: " + exception.Message);
            }
        }


convert it in vb.
 
Share this answer
 
Comments
[no name] 17-Jul-14 0:39am    
I already tried this but it is not working because i don't have _CommandBarButtonEvents_ClickEventHandler eventHandler;
this declaration.
nilesh sawardekar 17-Jul-14 2:29am    
have a look at http://support.microsoft.com/kb/302816
if you still facing problem, Let me know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900