【问题标题】:How to specify cursor placement and text format in an email using Outlook VBA如何使用 Outlook VBA 在电子邮件中指定光标位置和文本格式
【发布时间】:2020-06-25 16:08:16
【问题描述】:

我收到一位用户的请求,要求在 Outlook 中创建宏。

他的要求是有一个粗体、突出显示和斜体的电子邮件标题。

这部分我们能够完成,但他还要求光标最终位于邮件正文的标题下方,准备好使用他的常规格式选项(字体、大小、颜色)输入文本。

当前,当我们的宏运行时,光标最终位于电子邮件标题的开头。

如果将光标移动到标题下方的行,则文本仍为粗体和斜体。

有没有办法在插入标题后重置文本格式,有没有办法指定光标在标题下方结束?这是我们迄今为止提出的:

Sub Testmacro2()

    Dim olApp As Outlook.Application, olEmail As Outlook.MailItem, signature As String

    Set olApp = CreateObject("Outlook.Application")
    Set olEmail = olApp.CreateItem(0)
        With olEmail
        .Display
        End With
            signature = olEmail.HTMLBody
        With olEmail
        .HTMLBody = "<HTML><BODY><span style='background:yellow;mso-highlight:yellow'><em><b><p style=font-size:14pt>Privileged & Confidential Attorney Client Communication & Work Product.</b></em><br></span></BODY></HTML>" & vbNewLine & signature




    End With
Set olEmail = Nothing
Set olApp = Nothing

End Sub

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    您需要使用Inspector.WordEditor(返回Word.Document 对象的一个​​实例),即Inspector.WordEditor.Application.Selection

    Inspector 对象可以从MailItem.GetInspector 检索到。

    【讨论】:

    • 感谢您的意见。我会试试看。
    猜你喜欢
    • 1970-01-01
    • 2018-10-21
    • 2010-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多