我想将特定范围复制到邮件中(带图像)。
Sub Send_Range_Or_Whole_Worksheet_with_MailEnvelope()
'Working in Excel 2002-2016
Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Fill in the Worksheet/range you want to mail
'Note: if you use one cell it will send the whole worksheet
Set Sendrng = Worksheets("EMAIL").Range("B2:W41")
'Remember the activesheet
Set AWorksheet = ActiveSheet
With Sendrng
' Select the worksheet with the range you want to send
.Parent.Select
'Remember the ActiveCell on that worksheet
Set rng = ActiveCell
'Select the range you want to mail
.Select
' Create the mail and send it
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
.Introduction = "This is test mail 2."
With .Item
.To = ThisWorkbook.Sheets("EMAIL").Range("Z1").Value
.CC = ThisWorkbook.Sheets("EMAIL").Range("Z1").Value
.BCC = ""
.Subject = ThisWorkbook.Sheets("EMAIL").Range("D1").Value
.Display
End With
End With
'select the original ActiveCell
rng.Select
End With
'Activate the sheet that was active before you run the macro
AWorksheet.Select
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
End Sub
为什么 MailEnvelope 显示一秒钟,然后没有任何反应?
我更换了.Send
with .Display
但一切都没有改变。或者,我尝试使用 RNGtoHTML 代码,但该代码不复制图像(我在“EMAIL”工作表中有动态链接图片)。
尝试着跨过它。
当你运行脚本时,当你到达这行代码时,它会显示,
.display
但随后运行下面的代码将导致其停止显示。
ActiveWorkbook.EnvelopeVisible = False
如果您单步执行代码,您应该能够看到您的内容,直到到达上面的代码行。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)