以编程方式打开 Outlook 功能区控件

Open a Outlook ribbon control programatically

我正在开发一个 C# Office COM 插件,它有一个与约会消息相关联的相邻表单区域 class。我正在尝试通过代码打开功能区上的重复切换按钮。我试过 Office.CommandBars 接口和 FindControl() 通过控件 ID 引用控件。但它不起作用。任何帮助将不胜感激。提前致谢。

您可以尝试使用辅助功能 API 来模拟点击重复按钮。

您也可以尝试使用 Redemption (I am its author) and its SafeInspector 对象来做到这一点:

'simulate a click on the Recurrence button
set sInspector = CreateObject("Redemption.SafeInspector")
sInspector.Item = Application.ActiveInspector
set Ribbon =  sInspector.Ribbon
oldActiveTab = Ribbon.ActiveTab
Ribbon.ActiveTab = "Appointment"
set Control = Ribbon.Controls("Recurrence...")
Control.Execute
Ribbon.ActiveTab = oldActiveTab 'restore the active tab

在这种情况下,无需使用辅助功能 API 或兑换。

命令栏 class 的 ExecuteMso 方法允许在功能区上执行内置控件。在功能区上显示重复周期切换按钮时尝试使用以下代码:

commandBars.ExecuteMso("Recurrence");

命令栏对象应该来自Explorer 或Inspector 对象,取决于目标控件来自哪里。有关更多 IdMso 值,请参阅 Office 2013 Help Files: Office Fluent User Interface Control Identifiers