发送时,IMG范围为空 [英] Range to IMG is empty when sent

查看:49
本文介绍了发送时,IMG范围为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将此使用https://stackoverflow.com/a/48897439/14866652 作为图像Outlook电子邮件.

I use this https://stackoverflow.com/a/48897439/14866652 to a range as an image into an Outlook email.

我不想显示屏幕,所以我将 .Display 更改为 .Send .邮件发送为空:

I don't want the screen to display so I changed the .Display to .Send. The mail is sent empty:

Public Sub enviarmail()
    Dim rng As Range
    Dim olApp As Object
    Dim Email As Object
    Dim Sht As Excel.Worksheet
    Dim wdDoc As Word.Document
    
    Set Sht = ActiveWorkbook.Sheets("Cierre de ventas")
    Set rng = Sht.Range("B23:N35")
    rng.CopyPicture Appearance:=xlScreen, Format:=xlPicture
    
    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With
    
    Set olApp = CreateObject("Outlook.Application")
    Set Email = olApp.CreateItem(0)
    Set wdDoc = Email.GetInspector.WordEditor
    
    With Email
        .BodyFormat = 2
        .To = Range("D13").value
        .CC = Range("D14").value
        .Subject = Range("D15").value
           
        wdDoc.Range.PasteAndFormat Type:=wdChartPicture
        wdDoc.Range.InsertAfter vbLf & vbLf & "Firmado: " & Range("K13").value
 
        With wdDoc
            .InlineShapes(1).Height = 260
        End With
  
        .Send
            
    End With
    
    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With
    
    Set Email = Nothing
    Set olApp = Nothing
   
End Sub

更新:经过几次测试,@ urdearboy的潜在解决方法#2可以正常工作,也不需要使用缓冲区,我以前尝试过不使用缓冲区,但也没有使用它.

Update: after several tests, @urdearboy's Potential Workaround #2 works, no need to use a buffer too, I've tried before without the buffer and I did not got it to work.

同时使用 .Display .Send 即可.

推荐答案

潜在的解决方法#1

我遇到了类似的问题,当在文本或直接文件上传之外的对象中添加对象时,会发生.我唯一能够解决的方法是在要添加的文件和发送的电子邮件之间添加时间缓冲区.

Potential Workaround #1

I've ran into a similar issue that only occurs when adding objects to body outside of text or a direct file upload. The only way I have been able to solve is to add a time buffer between the file being added and the email being sent.

我知道这里的答案并不令人满意,但是值得一试:

I know the answer here is not satisfying, but worth a try:

Application.Wait Now + #12:00:01 AM#
.Send

这是我发布的问题.我对此表示赞赏,但仍然没有解决方案,所以最终还是解决了时间的延迟

Here is the question I posted with issue. I bountied this and still got no solution so settled with the time delay eventually

您还可以尝试先显示然后发送电子邮件.与上述相同,这似乎是解决实际问题的一种方法,但值得一试.如果您只是发送一封电子邮件,那么这可能是可以接受的途径.如果很多,那么它可能会减慢该过程并变得不太理想.

You can also try to first display and then send email. Same as above, this seems like a workaround to the actual problem but may be worth a try. If you are just sending one email then this could be a acceptable route to go. If many, then it may slow down the process and become less ideal.

With Email

    'Email Attributes
    .Display
    .Send

End With

这篇关于发送时,IMG范围为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆