我正在使用VSTO开发一个outlook插件。
在方法中:this.Load + = new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.MyApp_Load);
在我的功能区的MyApp_Load中,我使用以下代码:
if (Globals.ThisAddIn.isLoggedIn())
{
btnMyApp.Visible= true;
Outlook.Inspector inspector =
Globals.ThisAddIn.Application.ActiveInspector();
if (inspector != null && inspector.CurrentItem != null)
{
当我在Outlook中打开一个AppointmentItem时,我可以调试上面的代码。不幸的是,虽然正在显示有效的AppointmentItem,但ActiveInspector()== null。
为什么?
在显示检查器之前调用该方法。你必须使用RibbonUI
作为参数传递给你的onLoad
回调并将RibbonUI.Context
投射到Inspector
界面。