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事件.  
             
            }
        }
    }
  • 相关阅读:
    python常见的错误异常
    vim命令c编程
    递归函数初步理解---python实现(汉诺塔问题)
    python报错:AttributeError: module 'pdb' has no attribute 'set_trace'
    python程序控制结构
    python函数
    结构体的四种定义方法
    基于一维数组的桶排序入门
    双链表与单链表的比较
    在用free()函数释放指针内存时为何要将其指针置空
  • 原文地址:https://www.cnblogs.com/ddlzq/p/1661295.html
Copyright © 2011-2022 走看看