PowerPoint右键菜单下添加项目
泣之树 2015-05-18 01:28:14 目前在做一个用C#写的PowerPoint插件。其中一个功能就是想在右键菜单里添加两个项目比如“添加**”和“查询**”现在目前的情况是,我只能做到将这两项加在文件顶端的工具栏中。却怎么也加不到右键菜单中。如何将
这两个项目右键菜单中加到请各位大神指点。
下面是我的程序
using PPT = Microsoft.Office.Interop.PowerPoint;
using MSO = Microsoft.Office.Core;
using System.Windows.Forms;
using System.IO;
public void OnStartupComplete(ref System.Array custom){
commandbars = (applicationObject as PPT.Application).CommandBars;
//菜单命令
MSO.CommandBar fontRightPopup = null;
try
{
fontRightPopup = commandbars["Menu Bar"];//这个地方我试过很多参数都不好用
fontRightPopup.Reset();
eleImportForm = (MSO.CommandBarButton)fontRightPopup.Controls.Add(Before: 1);//菜单项的位置
eleImportForm.Caption = "添加**";
eleImportForm.Style = MSO.MsoButtonStyle.msoButtonCaption;
eleImportForm.Tag = "k";
eleImportForm.Click += new MSO._CommandBarButtonEvents_ClickEventHandler(EleImport_Click);//添加**_Click
assetManagement = (MSO.CommandBarButton)fontRightPopup.Controls.Add(Before: 2);//菜单项的位置
assetManagement.Caption = "查询**";
assetManagement.Style = MSO.MsoButtonStyle.msoButtonCaption;
assetManagement.Tag = "f";
assetManagement.Click +=
new MSO._CommandBarButtonEvents_ClickEventHandler(AssetManagement_Click);//资产管理_Click
eleImportForm.Visible = true;
assetManagement.Visible = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private object applicationObject;
private object addInInstance;
private MSO.CommandBarButton eleImportForm;//右键菜单选项(添加**)
private MSO.CommandBarButton assetManagement;//右键菜单选项(查询**)