none
Facing issues while creating excel plugins using dotnet RRS feed

  • Question

  • Hi All,

    I am working on the design of a Project and Need help. Appreciate a quick Response.

    The requirement goes like this -
    We Need to create a custom menu in Excel, after clicking on this menu item, dotnet code will be invoked from where some data has to be retreived from a Client site using webservices. This data must be displayed in the Excel sheet.

    Question:
    I have been successfully able to create a custom menu but when I try to add an Event such that an Action happens when the user clicks on the menu item, it throws an error - "Cannot assign to 'MenuItem_Click' because it is a 'method group'"

    MenuItem_Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(MenuItem_Click);

    I have added the following methods -  

           private void MenuItem_Click(Office.CommandBarButton Ctrl, ref Boolean CancelDefault)
            {
                MessageBox.Show(String.Format("You just clicked the button labeled '{0}. \n" + "The name of your workbook is '{1}'.", Ctrl.Caption, ThisWorkbook.name),
                                "MenuItem_Click",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
    
            private void ThisWorkbook_Startup(object sender, System.EventArgs e)
            {
                InitMenuBarItems("&Custom Code");
                MenuItem = CreateButton((Office.CommandBarPopup)MenuBarItem, "Run Demo Code");
                MenuItem_Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(MenuItem_Click);
            }
    
     
    

    Could anyone help me resolving this problem?
    Any help is highly appreciated.

    Thanks in advance.

    Friday, March 20, 2015 2:25 PM

Answers