outlook - 功能区无效不起作用

标签 outlook vsto outlook-addin

我有一个带有编辑框的简单 Outlook 功能区。用户单击发送按钮后,我将捕获 editBox 中的字符串并在 Application_ItemSend 中使用它。

我的问题是,功能完成后,我想重置功能区的用户界面(只是编辑框),以便用户在打开新消息屏幕时不会在同一个框中显示先前输入的字符串。我尝试了 Ribbon.Invalidate 但我似乎无法摆脱该字符串值。当我重新打开“新电子邮件”屏幕时,旧值仍然存在。

这是代码:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load_2010">
<ribbon>
<tabs>
  <tab idMso="TabNewMailMessage">
    <group id="TaskManager" insertBeforeMso="GroupSend" label="Task Manager">
      <editBox id="editboxTaskID" label="Task ID #: " onChange="editboxTaskID_OnChange" 
imageMso="RecordsAddFromOutlook" sizeString="wwwwww"/>
    </group>
  </tab>
</tabs>
</ribbon>
</customUI>

VB 代码:

<Runtime.InteropServices.ComVisible(True)> _
Public Class CustomRibbon
Implements Office.IRibbonExtensibility

Private ribbon As Office.IRibbonUI
Public strTask_ID As String = ""

Public Sub New()

End Sub

Public Function GetCustomUI(ByVal ribbonID As String) As String Implements Office.IRibbonExtensibility.GetCustomUI
    Return GetResourceText("Addin.Ribbon.xml")
End Function

Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean)
    Me.ribbon.Invalidate()
    Try

 'SOME CODE HERE WHICH WORKS FINE!

    Catch ex As Exception
    End Try

End Sub


'Create callback methods here. For more information about adding callback methods, select the Ribbon XML item in Solution Explorer and then press F1.
Public Sub Ribbon_Load_2010(ByVal ribbonUI As Office.IRibbonUI)
    Me.ribbon = ribbonUI
    AddHandler Globals.ThisAddIn.Application.ItemSend, AddressOf Application_ItemSend
End Sub

Public Sub editboxTaskID_OnChange(ByVal control As Office.IRibbonControl, ByVal Text As String)
    strTask_ID = Text
End Sub

Public Sub AttachmentRibonClick(ByVal control As Microsoft.Office.Core.IRibbonControl)
    Globals.ThisAddIn.TriggerTaskWindow("Attachment")
End Sub

Private Shared Function GetResourceText(ByVal resourceName As String) As String
    Dim asm As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
    Dim resourceNames() As String = asm.GetManifestResourceNames()
    For i As Integer = 0 To resourceNames.Length - 1
        If String.Compare(resourceName, resourceNames(i), StringComparison.OrdinalIgnoreCase) = 0 Then
            Using resourceReader As IO.StreamReader = New IO.StreamReader(asm.GetManifestResourceStream(resourceNames(i)))
                If resourceReader IsNot Nothing Then
                    Return resourceReader.ReadToEnd()
                End If
            End Using
        End If
    Next
    Return Nothing
End Function
End Class

最佳答案

invalidate 方法用于指示控件已更新并且需要在屏幕上重新呈现。它不会清除控件中的数据。您需要做的是将控件(本例中为编辑框)上的属性设置为将有问题的字符串值存储为空字符串。

关于outlook - 功能区无效不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13268854/

相关文章:

vba - 使用 VBA 宏选择和复制 Outlook 电子邮件正文

c# - VSTO Excel Com 添加功能区未加载

javascript - Outlook Web 插件 : how to redirect to other page?

outlook-addin - Outlook Web 插件 : Ribbon button grayed out in Explorer view in Email

.net - CreateRibbonExtensibilityObject 仅创建一个功能区对象 - Outlook 2010 Addin

excel - 如何在 Excel 中使用 VBA 将附件添加到电子邮件

Outlook 2013 中的 HTML 电子邮件未对齐?

regex - 如何替换电子邮件中两个关键词之间的句子?

migration - Visual Studio 2015 办公室 2007

c# - Outlook 加载项的弹出通知(从后台线程问题调用 Form.Show())