无效功能区:Outlook VSTO 4

时间:2018-05-16 13:10:20

标签: .net vsto outlook-addin

我尝试在VSTO 4 Outlook 365/2016 AddIn期间启用/禁用按钮。 它不是XML代码,而是"纯.NET"

似乎Invalidade()方法仅适用于尚未显示TAB-Ribbon的情况。

我的意思是,如果我尝试在启动代码中启用/禁用按钮(我为"处理/打开"和"新"处理消息事件),我没有成功。

但是,在显示TAB(并且所有按钮都已启用)之后,如果我按下其中一些并且无效(控制),一切都正常。

问题:

  • 如果没有强制用户按下按钮,有没有办法让按钮无效?
  • 如果没有,有没有办法强制显示我的TAB和Invalidate()一些控件呢?

我感谢任何帮助。

更新

这是我在VB.NET中的代码:

Private WithEvents Inspectores As Outlook.Inspectors


Private Sub ThisAddIn_Startup() Handles Me.Startup


    Inspectores = Me.Application.Inspectors
    AddHandler Inspectores.NewInspector, AddressOf MessageActivity

End Sub



Friend Sub MessageActivity(ByVal Item As Object)


    Dim Status As Outlook.MailItem = TryCast(Item.currentitem, Microsoft.Office.Interop.Outlook.MailItem)


    If TypeOf Status Is MailItem Then

        If Status IsNot Nothing Then
            Try
                If Status.EntryID Is Nothing Then
                    AddHandler Status.Open, AddressOf NewingMessage
                Else
                    AddHandler Status.Read, AddressOf ReadingMessage
                End If

            Catch ex As system.Exception
                MsgBox(ex.message)
            End Try

        End If

    End If

End Sub


Sub ReadingMessage()

    Dim ribbonCollection As ThisRibbonCollection = Globals.Ribbons _
   (Globals.ThisAddIn.Application.ActiveInspector())


    'MsgBox("Opening")

    IsNotReallyNew = True

    ribbonCollection.Ribbon1.ObkRead.Enabled = True
    ribbonCollection.Ribbon1.Button1.Enabled = False
    ribbonCollection.Ribbon1.btnSign.Enabled = False
    ribbonCollection.Ribbon1.btnEncode.Enabled = False
    ribbonCollection.Ribbon1.Button3.Enabled = False

    ribbonCollection.Ribbon1.RibbonUI.Invalidate()

End Sub

0 个答案:

没有答案