简体   繁体   English

启动Outlook功能区添加

[英]Start Outlook add in with ribbon

I'm developing an Outlook Add In. 我正在开发Outlook加载项。 It's pretty much done already, but there's one thing that I can't seem to put my finger on. 它已经完成了很多,但是有一件事我似乎无法动弹。 In my (Outlook Add In) project I added a new item (Ribbon (Visual Designer)) which I called EmailTransferRibbon. 在我的(Outlook加载项)项目中,我添加了一个名为EmailTransferRibbon的新项目(Ribbon(可视设计器))。 This Ribbon is being displayed in Outlook. 此功能区正在Outlook中显示。 I want to be able to start my Outlook Add In when I click on this Ribbon button. 当我单击此功能区按钮时,我希望能够启动Outlook加载项。

This is what my Ribbon looks like: 这是我的功能区的样子:

public partial class EmailTransferRibbon
{
    private void EmailTransferRibbon_Load(object sender, RibbonUIEventArgs e)
    {   
    }

    private void btnEmailTransfer_Click(object sender, RibbonControlEventArgs e)
    {
    }
}

And this is the add in where I want the Ribbon button to navigate to: 这是我希望“功能区”按钮导航到的位置:

public partial class ThisAddIn
{
    EmailTransferForm emailTransferForm = new EmailTransferForm();

    public void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        InboxFolderItemAdded();
        Button btnRefresh = emailTransferForm.Controls.Find("btnRefresh", true).FirstOrDefault() as Button;
        btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);

    }
}

I tried to do something like this, but this is a problem because RibbonControlEventArgs is not the same as System EventArgs: 我试图做这样的事情,但这是一个问题,因为RibbonControlEventArgs与System EventArgs不同:

var addIn = Globals.ThisAddIn;
addIn.ThisAddIn_Startup(sender, e);

Can someone tell me how to start the my add in by pressing the Ribbon button? 有人可以告诉我如何通过按功能区按钮来启动我的添加吗? thanks! 谢谢!

You can set your add-in to "load on demand", which can create your Ribbon UI and effectively cache your add-in until you want to load it completely: 您可以将加载项设置为“按需加载”,这可以创建功能区UI并有效地缓存您的加载项,直到您想完全加载它:

Demand-Loading VSTO Add-ins - Andrew Whitechapel - Site Home - MSDN Blogs http://blogs.msdn.com/b/andreww/archive/2008/07/14/demand-loading-vsto-add-ins.aspx 需求加载VSTO加载项-Andrew Whitechapel-网站主页-MSDN博客http://blogs.msdn.com/b/andreww/archive/2008/07/14/demand-loading-vsto-add-ins.aspx

If you don't want your add-in to load at all until you click a button, then that button will need to call VBA code to load your add-in, or the button needs to be powered by another add-in that will load your add-in. 如果您根本不希望在单击某个按钮之前加载该加载项,则该按钮将需要调用VBA代码以加载该加载项,或者该按钮需要由另一个加载项供电加载您的加载项。 In either case, you need to use the Office Object Model to access the COMAddins collection from Outlook.Application.COMAddINs and get the specific COMAddIn object for your add-in (matching on the ProgID value) and set Connect = True to load your add-in. 无论哪种情况,您都需要使用Office对象模型从Outlook.Application.COMAddINs访问COMAddins集合,并为您的加载项获取特定的COMAddIn对象(与ProgID值匹配),并设置Connect = True来加载您的添加项-在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM