k is '{2}'.", _ Ctrl.Caption, Environment.NewLine, ThisWorkbook.Name), _ "MenuItem_Click", MessageBoxButtons.OK, _ MessageBoxIcon.Information) 4.选择文件菜单中的保存所有文件来保存整个解决方案。 5.按F5运行这个项目,装入Excel和你的工作簿。 6.在Excel中,点击Custom Code菜单,接着选择Run Demo Code。 一个警告框出现,显示当前工作簿。 (C#)拦截点击菜单项目事件 在Visual C#中完成下列步骤来增加点击自定义菜单栏项目的事件处理。 为自定义菜单项目增加事件处理(C#) 1.增加下列程序到OfficeCodeBehind类中: // C# 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); } 页码:[1] [2] [3] [4] [5] [6] [7] [8] [9] 第8页、共9页 |