使用 VBA 将自定义组添加到 Outlook 2010 中的“主页”选项卡

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3812818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:07:34  来源:igfitidea点击:

Add custom group to Home tab in Outlook 2010 using VBA

vbaribbonribbon-controloutlook-2010

提问by Trindaz

Can't seem to find any simple VBA tutorials for adding a custom group to the Home tab in the Outlook 2010 ribbon.

似乎找不到任何简单的 VBA 教程,用于将自定义组添加到 Outlook 2010 功能区中的“主页”选项卡。

Shouldn't it be a couple of simple steps involving something like traversing objects in the Home tab and programmatically add the group with controls etc, or redefine the XML that describes the Home tab.

它不应该是几个简单的步骤,包括遍历 Home 选项卡中的对象并以编程方式添加带有控件的组等,或者重新定义描述 Home 选项卡的 XML。

Is there any sample VBA code or articles that have this simple example? Specifically I'm trying to add a custom group with 1 text field and 1 button that fires a custom macro.

是否有任何具有这个简单示例的示例 VBA 代码或文章?具体来说,我正在尝试添加一个带有 1 个文本字段和 1 个触发自定义宏的按钮的自定义组。

Cheers, Dave --Trindaz on Fedang #outlook-2010-vba

干杯,戴夫——费当的特林达兹 #outlook-2010-vba

回答by Trindaz

I wasn't able to get any VBA working for this, but I was able to...

我无法让任何 VBA 为此工作,但我能够......

  1. Create a new Outlook 2007 project type in Visual Studio 2008
  2. Add a new Ribbon (XML) item to the project
  3. Follow the instructions in the sample code in the newly created Ribbon1.vb
  4. Make sure the <tab>element in Ribbon1.xml has property idMso="TabMail"
  5. Publish and run the installer application to get the new items appearing in the Home tab of the Outlook ribbon
  1. 在 Visual Studio 2008 中创建新的 Outlook 2007 项目类型
  2. 向项目添加新的功能区 (XML) 项
  3. 按照新创建的 Ribbon1.vb 中示例代码中的说明进行操作
  4. 确保<tab>Ribbon1.xml 中的元素具有属性idMso="TabMail"
  5. 发布并运行安装程序应用程序以使新项目出现在 Outlook 功能区的“主页”选项卡中

Done!

完毕!

回答by Joe Almore

Another answer using Ribbon XML for Outlook 2010:

使用功能区 XML for Outlook 2010 的另一个答案:

 <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <ribbon>
    <tabs>
      <tab idMso="TabMail">
        <group id="Group0"  label="my Group" insertBeforeMso="GroupMoveActions">
          <button id="myButton"
              size="large"
              label="someLabel"
              screentip="A tip to read..."
              supertip="Some super tip..."
              />
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

You can also download this file: Office 2010 Help Fileswhich contains the IDs of the Outlook controls. Once installed, look for the file OutlookExplorerControls.xlsx, this file contains the names of the groups you can use for the property insertBeforeMso.

您还可以下载此文件:Office 2010 帮助文件,其中包含 Outlook 控件的 ID。安装后,查找文件OutlookExplorerControls.xlsx,该文件包含可用于属性insertBeforeMso的组的名称。