Excel VBA将Word Doc复制到Outlook中-图像消失

时间:2019-01-04 22:38:04

标签: excel vba image outlook ms-word

我正在使用将Word文档复制到剪贴板,然后将其粘贴到Outlook对象主体中的技术。当我在Windows 10计算机上运行代码时,它的工作原理就像一种魅力,但是,当我尝试在Windows 7计算机上运行具有相同word文档副本的确切代码时,除图像外的所有内容都会被复制。有什么想法会导致这种情况,以及是否有解决方法?

赞赏任何想法。我被Google淘汰了,还没有找到解决方法。

这是代码 放置在剪贴板上

'
    Set wd = CreateObject("Word.Application")
    Set doc = wd.documents.Open(WordFile)
    doc.Content.Copy
    doc.Close
    Set wd = Nothing

'   Here is the code to setup and send email

'
            Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next
'
            With OutMail
'
                .To = cell.Value
                .Subject = TSubject
'
'          Customize Saluation
'
                cusname = Cells(cell.Row, "A").Value
                SalLines = Salutation & " " & cusname & vbCrLf
'
                .BodyFormat = olFormatRichText

                Set editor = .GetInspector.WordEditor
                editor.Content.Paste
 '     Without the following line the content does not appear
                .Display
'
                .htmlbody = SalLines & .htmlbody
'
'
                .Display
                .Send
'
                'You can add files also like this
                '.Attachments.Add ("C:\test.txt")
'
'
            End With

1 个答案:

答案 0 :(得分:1)

问题解决了。通过在插入称呼之前添加一个额外的Bodyformat = olformathtml,一切正常。

相关问题