r> ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Function // C# private Office.CommandBarButton CreateButton( Office.CommandBarPopup Parent, string Caption) { Office.CommandBarControl cbc = null; try { cbc = Parent.Controls.Add( Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true); cbc.Caption = Caption; cbc.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } return (Office.CommandBarButton) cbc; } 2.增加下列代码到ThisWorkbook_Open程序中,下列代码调用了InitMenuBarItems程序: ' Visual Basic MenuItem = CreateButton( _ DirectCast(MenuBarItem, Offic页码:[1] [2] [3] [4] [5] [6] [7] [8] [9] 第6页、共9页 |