zoukankan      html  css  js  c++  java
  • 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事件.  
             
            }
        }
    }
  • 相关阅读:
    H5学习的第三周
    2017.3.12 H5学习的第一周
    js中比较实用的函数用法
    JS学习中遇到的一些题目
    H5学习第四周
    idea快捷键
    中国国内可用API合集
    ssm整合 idea+maven版
    Dubbo的使用及原理浅析
    $.extend 和$.fn.extend的区别
  • 原文地址:https://www.cnblogs.com/ddlzq/p/1661295.html
Copyright © 2011-2022 走看看