How add menuitem in word in c# -


i have tried code add new menu item in word document on right click. there 1 problem

error: 'this.application' line give error of statement not in current context. solution package required line or solution.

word.application application;  private void thisaddin_startup(object sender, system.eventargs e) {     application = this.application;     application.windowbeforerightclick +=         new word.applicationevents4_windowbeforerightclickeventhandler(application_windowbeforerightclick);      application.customizationcontext = application.activedocument;      office.commandbar commandbar = application.commandbars["text"];     office.commandbarbutton button = (office.commandbarbutton)commandbar.controls.add(         office.msocontroltype.msocontrolbutton);     button.accname = "my custom button";     button.caption = "my custom button"; }  public void application_windowbeforerightclick(word.selection selection, ref bool cancel) {     if (selection != null && !string.isnullorempty(selection.text))     {         string selectiontext = selection.text;          if (selectiontext.contains("c#"))             setcommandvisibility("my custom button", false);         else             setcommandvisibility("my custom button", true);     } }  private void setcommandvisibility(string name, bool visible) {     application.customizationcontext = application.activedocument;     office.commandbar commandbar = application.commandbars["text"];     commandbar.controls[name].visible = visible; } 


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -