• VSTO EXCEL篇学习笔记四【原】


    使用VSTO创建嵌入EXCEL菜单

    该段代码是一个创建菜单的例子。

    代码
    using Microsoft.Office.Core;                                    //需要引用这个命名空间,vsto与菜单相关的类在该命名空间中
    using Microsoft.Office.Interop.Excel ;

    //using System.Reflection; 
    //作者:ERIc
    //日期:2009年5月
    //功能:生产主系统菜单
    namespace Excel.Common
    {
        
    public class ExcelBulidMainMenu
        {
            
    static Microsoft.Office.Core.CommandBar menuBar;              //实例化一个菜单条,该对象为静态对象,这样每个实例化该类的WorkBook都可以引用同一个菜单实例.
            static Microsoft.Office.Core.CommandBarPopup menuCustom;      //实例化一个弹出菜单对象.

            
    static Microsoft.Office.Core.CommandBarButton menu1;          //实例化一个菜单项.
            public void  BulidMainMenu(Workbook  _self)
            {
                menuBar 
    = _self.Application.CommandBars.ActiveMenuBar;
                menuCustom 
    =
                    (Microsoft.Office.Core.CommandBarPopup)menuBar.Controls.Add
                    (Microsoft.Office.Core.MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, 
    true);
                menuCustom.Caption 
    = "系统管理(&S)";
                menu1 
    =
                   (Microsoft.Office.Core.CommandBarButton)menuCustom.Controls.Add
                   (Microsoft.Office.Core.MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, 
    true);
                menu1.Caption 
    = "登入系统(&E)";
                menu1.Click 
    +=
                    
    new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(menu1_Click);    //托管菜单项的Click事件.  
             
            }
        }
    }
  • 相关阅读:
    git切换分支报错解决
    网上看到的一个布局神器
    js获取滚动条,文档,浏览器高度
    使用iView-cli创建一个pc端网页(1)
    ajax详解与用途
    JavaScript中for/in和for的区别
    排序
    Java中getResourceAsStream的用法
    java程序打包成exe的总结
    使用7zip把jre集成到绿色运行程序内
  • 原文地址:https://www.cnblogs.com/ddlzq/p/1661295.html
Copyright © 2020-2023  润新知