【问题标题】:How to replace text in the InlineResponse window?如何替换 InlineResponse 窗口中的文本?
【发布时间】:2021-06-30 02:43:52
【问题描述】:

我需要对我在 Outlook 2016 中转发或回复的电子邮件执行修改。

以下代码在 InlineResponse 窗口中执行修改(将正则表达式值替换为空):

Dim myOlApp As New Outlook.Application
Public WithEvents myOlExplorer As Outlook.Explorer

Public Sub Initialize_handler()
    Set myOlExplorer = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExplorer_InlineResponse(ByVal Item As Object)
    ' first replace using the word editor
    Dim oDoc As Word.Document
    Dim wdSelection As Word.Selection
    Set oDoc = Item.GetInspector.WordEditor
    Set wdSelection = oDoc.Application.Selection
    wdSelection.Find.ClearFormatting
    wdSelection.Find.replacement.ClearFormatting
    With wdSelection.Find
        .Text = "SPECIFIC TEXT WITH A VARIABLE LENGTH OF SPACES OF DIFFERENT KINDS AFTER THAT I NEED TO INCLUDE [!a-zA-Z0-9]*([a-zA-Z0-9])" ' my regex goes in here the a-zA-Z0-9 part is to work around the non-greedy regex.
        .replacement.Text = "\1"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    wdSelection.Find.Execute Replace:=wdReplaceAll
End Sub

当我运行这段代码(总体上运行良好)时,Outlook 的一些默认行为被破坏了。

例子:

  • 草稿消息未保存。如果我点击回复,请在内联响应窗口中输入一些内容并留下该消息,当返回时,工作就消失了
  • 无法从剪贴板粘贴

也许更多的功能被破坏了。

是什么原因造成的,我们可以做些什么来防止这种情况发生?

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    您必须使用特定属性从内联响应中获取 Word 文档:Explorer.ActiveInlineResponseWordEditor。

    【讨论】:

    • 在这种情况下:myOlExplorer.ActiveInlineResponseWordEditor
    猜你喜欢
    • 2012-01-31
    • 2018-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-07
    • 2016-11-12
    • 1970-01-01
    相关资源
    最近更新 更多