【问题标题】:Paste range from word in mail body including the format粘贴邮件正文中单词的范围,包括格式
【发布时间】:2020-07-19 13:08:05
【问题描述】:

我正在处理邮件合并宏,我正在尝试从我的 word 文档中复制文本,包括邮件正文中的格式,不幸的是它不接受 range.paste 函数。 期待任何建议。

    Set oWord = CreateObject("Word.Application")

    oWord.Documents.Open FileName:="*\Flightticket.docx", ReadOnly:=True
    Set oDoc = oWord.ActiveDocument
    Set oRange = ActiveDocument.Range(Start:=0)
    oWord.Visible = False
    oRange.Copy

*
*
*
           With oMail
               .To = oContact.Email1Address
               .Subject = Left(oDoc.Name, Len(oDoc.Name) - 5) & " " & mText
               .GetInspector.Activate 'Signatur
               olOldBody = .HTMLBody
               'The content of the document is used as the body for the email
                .HTMLBody = oRange.Paste  & olOldBody               'Here is the error
             End With 

【问题讨论】:

    标签: vba outlook ms-word paste


    【解决方案1】:

    我现在解决了这个问题,将 html 代码添加到我的 word 文档中,并且在没有复制粘贴的情况下包含了整个内容。效果很好。

    .HTMLBody = oDoc.Content & olOldBody
    

    【讨论】:

      【解决方案2】:
      .HTMLBody = oRange.FormattedText  & olOldBody  
      

      【讨论】:

      • 谢谢,它不会导致错误,但也不会使用文本的格式
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 1970-01-01
      • 2018-09-06
      • 2019-08-02
      • 1970-01-01
      • 1970-01-01
      • 2021-03-18
      相关资源
      最近更新 更多