【问题标题】:Open a Outlook ribbon control programatically以编程方式打开 Outlook 功能区控件
【发布时间】:2022-05-03 23:14:18
【问题描述】:

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

【问题讨论】:

    标签: vsto outlook-addin outlook-2010


    【解决方案1】:

    在这种情况下,无需使用 Accessibility API 或 Redemption。

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

    commandBars.ExecuteMso("Recurrence");
    

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

    【讨论】:

    • 工作就像一个魅力!谢谢!
    【解决方案2】:

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

    您也可以尝试使用Redemption(我是它的作者)和它的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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-23
      相关资源
      最近更新 更多