【问题标题】:Highlight Text in Reading Pane在阅读窗格中突出显示文本
【发布时间】:2016-11-16 15:04:15
【问题描述】:

我试图在阅读窗格中突出显示特定文本,因此当您单击特定电子邮件时,阅读窗格将显示电子邮件的正文并突出显示指定的文本,在本例中为“测试”一词。

目前,什么都没有发生。

如果我双击电子邮件在新窗口中打开它,阅读窗格中它后面的预览现在会正确突出显示。
似乎事件在打开而不是预览时触发,然后更改对不再位于顶部的窗口生效。

Public WithEvents myItem As Outlook.MailItem

Private Sub Application_ItemLoad(ByVal Item As Object)
    If Item.Class = olMail Then
        Set myItem = Item
    End If
End Sub


Private Sub myItem_Open(Cancel As Boolean)
    EventsDisable = True
   
    Dim msg As Outlook.MailItem
    Dim insp As Outlook.Inspector

    Set insp = Application.ActiveInspector

    If insp.CurrentItem.Class = olMail Then
    Set msg = insp.CurrentItem

        If insp.EditorType = olEditorWord Then
            Set hed = msg.GetInspector.WordEditor
            Set appWord = hed.Application
            Set rng = appWord.Selection
            rng.Find.HitHighlight ("Test")
        End If
    
    End If

    Set appWord = Nothing
    Set insp = Nothing
    Set rng = Nothing
    Set hed = Nothing
    Set msg = Nothing
    EventsDisable = False
    
End Sub

【问题讨论】:

    标签: vba email outlook outlook-2013


    【解决方案1】:

    不要使用ActiveInspector - 它与资源管理器显示的项目无关。 试试下面的

    set hed = Application.ActiveExplorer.Selection(1).GetInspector.WordEditor
    

    请记住,如果项目显示在检查器中并且在活动浏览器中被选中,则上述更改将仅在检查器中突出显示文本,预览窗格不会受到影响。如果您想始终使用预览窗格,您可能需要查看 Redemption 及其明确公开阅读窗格的 SafeExplorer 对象:

    set sExplorer = CreateObject("Redemption.SafeExplorer")
    sExplorer.Item = Application.ActiveExplorer
    set hed = sExplorer.ReadingPane.WordEditor
    Set appWord = hed.Application
    Set rng = appWord.Selection
    rng.Find.HitHighlight ("Test")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-13
      • 2017-07-09
      • 1970-01-01
      • 2013-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-25
      相关资源
      最近更新 更多