thoughttore.blogg.se

Add microsoft word to new file menu
Add microsoft word to new file menu




add microsoft word to new file menu
  1. #Add microsoft word to new file menu update#
  2. #Add microsoft word to new file menu code#

List mindex = new List() ĪddItemGeneral(applicationObject.CommandBars, youreventHandler, "yourTagLabelplusaDiffNumber" + item.ToString(), "your Caption") įinally, private void AddItemGeneral(CommandBar popupCommandBar, _CommandBarButtonEvents_ClickEventHandler MyEvent, string MyTag,string M圜aption)ĬommandBarButton commandBarButton = (MsoControlType.msoControlButton, missing, MyTag, missing) as CommandBarButton ĬommandBarButton = (CommandBarButton)(MsoControlType.msoControlButton, Missing.Value, Missing.Value, + 1, true) Īs Dirk indicated, you need to click the EDIT link under your original question, paste the information in your "answer" at the end of it, then delete the "answer" - it's not an answer.

#Add microsoft word to new file menu code#

Someting like under code use this on your Startup Function try

#Add microsoft word to new file menu update#

So, you must update your code by foreach to iterate the create new commandBarButtons These are contains the indexes of text, table, heading, textBox and. add the button to the context menus that you need to supportĪddButton(applicationObject.CommandBars) įirst of all, there are more than 200 different contextmenu for RightClickīut the common type of are base on under Indexes (MsoControlType.msoControlButton, missing, missing, missing, true) ĭebug.WriteLine("Created new button, adding handler") Var commandBarButton = (CommandBarButton) Something like the following: private void AddButton(CommandBar popupCommandBar)įoreach (var commandBarButton in ())ĭebug.WriteLine("Found existing button. So I would suggest that you extract a method that adds a button to a CommandBar and then you call that method with all the command bars where you want to add your button to. Tables have a different context menus depending on what is selected when you click: However, to add something to the context menu of a table you have to add your button to the appropriate table-related context menu. The command bar that is used in the linked sample is the one named "Text" and this one is related to the context menu that pops up when you right-click somewhere in the text of a paragraph. Where(cb => cb.Position = MsoBarPosition.msoBarPopup)) You can see all of them by enumerating all CommandBar objects in Application.CommandBars whose position is msoBarPopup: foreach (var commandBar in () Word maintains more than one context menu.

add microsoft word to new file menu

I can not add the item menu when i right click on a table of ms word. Check out the screenshot to see what I mean: Show("Hello !!! Happy Programming", "l19 !!!") Īnd the result when i right click on a letter :īut with a table I cannot do it. Private void MyButton_Click(CommandBarButton cmdBarbutton, ref bool cancel) This.Shutdown += new System.EventHandler(ThisAddIn_Shutdown) This.Startup += new System.EventHandler(ThisAddIn_Startup) / the contents of this method with the code editor. / Required method for Designer support - do not modify Word.Application App = as Word.Application Īpp.WindowBeforeRightClick -= new .ApplicationEvents4_WindowBeforeRightClickEventHandler(App_WindowBeforeRightClick) Private void ThisAddIn_Shutdown(object sender, System.EventArgs e) ("Created new button, adding handler") ĬommandBarButton commandBarButton = _object as CommandBarButton Will attach a handler.") ĬommandBarButton = (CommandBarButton)(MsoControlType.msoControlButton, missing, missing, missing, true) ("Found button, attaching handler") ĬommandBar popupCommandBar = applicationObject.CommandBars įoreach (object _object in popupCommandBar.Controls)ĬommandBarButton _commandBarButton = _object as CommandBarButton Void App_WindowBeforeRightClick(.Selection Sel, ref bool Cancel)ĬommandBarButton commandBarButton = (MsoControlType.msoControlButton, missing, "HELLO_TAG", missing) as CommandBarButton MessageBox.Show("Error: " + exception.Message) Word.Application applicationObject = as Word.Application ĪpplicationObject.WindowBeforeRightClick += new .ApplicationEvents4_WindowBeforeRightClickEventHandler(App_WindowBeforeRightClick) Here is my code: private void ThisAddIn_Startup(object sender, System.EventArgs e)ĮventHandler = new _CommandBarButtonEvents_ClickEventHandler(MyButton_Click) I tried to create a right-click menu item in Microsoft Word based on this post.






Add microsoft word to new file menu