【问题标题】:Insert the contents of a Word Document into an email and include the default signature using VBA将 Word 文档的内容插入电子邮件并使用 VBA 包含默认签名
【发布时间】:2018-09-18 16:32:12
【问题描述】:

我在How to send a Word document as body of an email with VBA 中使用了 Patrick Wynne 提供的代码,但它覆盖了签名。粘贴word文档内容时,有没有办法更改代码以保留默认签名?

代码如下:

Sub emailFromDoc()
    Dim wd As Object, editor As Object
    Dim doc As Object
    Dim oMail As MailItem

    Set wd = CreateObject("Word.Application")
    Set doc = wd.documents.Open(...path to your doc...)
    doc.Content.Copy
    doc.Close
    set wd = Nothing

    Set oMail = Application.CreateItem(olMailItem)
    With oMail
        .BodyFormat = olFormatRichText
        Set editor = .GetInspector.WordEditor
        editor.Content.Paste
        .Display
    End With
End Sub

【问题讨论】:

标签: vba outlook ms-word


【解决方案1】:

你可能会使用:

Sub emailFromDoc()
    Dim wd As Object, editor As Object
    Dim doc As Object
    Dim Rng As Object
    Dim oMail As MailItem

    Set wd = CreateObject("Word.Application")
    Set doc = wd.documents.Open(...path to your doc...)
    doc.Content.Copy
    doc.Close
    Set wd = Nothing

    Set oMail = Application.CreateItem(olMailItem)
    With oMail
        .BodyFormat = olFormatRichText
        Set editor = .GetInspector.WordEditor
        Set Rng = editor.Content
        Rng.Collapse 1
        Rng.Paste
        .Display
    End With
End Sub

【讨论】:

  • 成功了。谢谢!它肯定胜过我使用 SendKeys 实现的临时解决方法。
猜你喜欢
  • 2013-10-06
  • 1970-01-01
  • 2015-03-23
  • 1970-01-01
  • 2014-10-16
  • 2012-11-02
  • 2017-09-08
  • 2016-06-07
  • 1970-01-01
相关资源
最近更新 更多