你调用的对象是空的。 - Outlook 2010添加上下文选项卡按钮

时间:2013-05-10 19:15:55

标签: outlook-addin

我在浏览Outlook 2010 Addin项目中的所选附件列表时遇到问题。

这是ribbon1.xml

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <ribbon>
    <contextualTabs>
      <tabSet idMso="TabSetAttachments">
        <tab idMso="TabAttachments">
          <group label="DWOS" id="DWOSAttachmentGroup">
            <button id="btnSendToJobOrder"
                size="large"
                label="Send to Job/Order"
                getImage="GetButtonImage"
                onAction="OnMyButtonClick" />
          </group>
        </tab>
      </tabSet>
    </contextualTabs>
  </ribbon>
</customUI>

这是我的OnMyButtonClick事件:

 Public Sub OnMyButtonClick(ByVal control As Office.IRibbonControl)
    Dim attachmentSelection As AttachmentSelection = TryCast(control.Context, AttachmentSelection) '<-- Error Here

    For Each attachment As Outlook.Attachment In attachmentSelection
        ' Do Something
    Next

End Sub

非常感谢任何帮助。

0 个答案:

没有答案