当前位置:软件学习 > outlook >>

给Outlook 2007的Calendar视图增加个右键菜单项

实现环境:Visual Studio 2010, Office 2007, VSTO 4.0

[csharp]
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Xml.Linq; 
using Outlook = Microsoft.Office.Interop.Outlook; 
using Office = Microsoft.Office.Core; 
 
namespace OutlookAddIn7 

    public partial class ThisAddIn 
    { 
        private void ThisAddIn_Startup(object sender, System.EventArgs e) 
        { 
            Application.ViewContextMenuDisplay += new Outlook.ApplicationEvents_11_ViewContextMenuDisplayEventHandler(Application_ViewContextMenuDisplay); 
        } 
 
        void Application_ViewContextMenuDisplay(Office.CommandBar CommandBar, Outlook.View View) 
        { 
            if (View is Outlook.CalendarView) 
            { 
                Office.CommandBarButton btn = (Office.CommandBarButton)CommandBar.Controls.Add(); 
                btn.Caption = "Test"; 
            } 
        } 
 
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e) 
        { 
        } 
 
        #region VSTO generated code 
 
        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor. 
        /// </summary> 
        private void InternalStartup() 
        { 
            this.Startup += new System.EventHandler(ThisAddIn_Startup); 
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); 
        } 
        
        #endregion 
    } 


摘自 TX_OfficeDev的专栏
补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,