c#中excel编程中ThisWorkbook_Startup(object sender, System.EventArgs e)的
            Office.CommandBar menuBar = this.Application.CommandBars.ActiveMenuBar;
            Office.CommandBarPopup menuCustom = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true);
            menuCustom.Caption = "页面生成";            Office.CommandBarButton menu1 = (Office.CommandBarButton)menuCustom.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
            menu1.Caption = "开始生产页面(&G)";
            menu1.Click += new Office._CommandBarButtonEvents_ClickEventHandler(menu1_Click);
第一次执行menu1_Click可以,以后再执行menu1_Click时就没有反映了
谢谢!

解决方案 »

  1.   

    楼主的意思是不是想实时反映读取或导出excel的状况?
    如果是这样的话,建议用Progressbar
      

  2.   

    我在自己机器上试了一下,没有问题,每次都可以执行。Excel 2003是不是menu1_Click这个过程里有问题?
    楼主可以把menu1_Click里的代码全注释掉,看看执行完一个空过程的menu1_Click后是不是还能再触发menu1_Click,如果代码注释掉后menu1_Click每次都能触发,那就是现在的menu1_Click里的代码有问题了。
      

  3.   

            private void menu1_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
           {    
                SetRange frm = new SetRange();
                string ss = "";
                if (frm.ShowDialog() == DialogResult.OK)
                {
                      gei.AnalysisExcel();
                      gei.MakeWeb();
                }
                else
                {
                    return;
                }
           }