java 邮件 显示图表,发送Excel范围,包括电子邮件图表

我在修改宏而无法复制选定的数据范围并通过电子邮件将其发送到特定地址时遇到问题 .

我从以下工作代码开始:

Sub Mail_Range()

'Working in Excel 2000-2016

'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm

Dim Source As Range

Dim Dest As Workbook

Dim wb As Workbook

Dim TempFilePath As String

Dim TempFileName As String

Dim FileExtStr As String

Dim FileFormatNum As Long

Dim OutApp As Object

Dim OutMail As Object

Set Source = Nothing

On Error Resume Next

Set Source = Range("A1:K50").SpecialCells(xlCellTypeVisible)

On Error GoTo 0

If Source Is Nothing Then

MsgBox "The source is not a range or the sheet is protected, please correct and try again.", vbOKOnly

Exit Sub

End If

With Application

.ScreenUpdating = False

.EnableEvents = False

End With

Set wb = ActiveWorkbook

Set Dest = Workbooks.Add(xlWBATWorksheet)

Source.Copy

With Dest.Sheets(1)

.Cells(1).PasteSpecial Paste:=8

.Cells(1).PasteSpecial Paste:=xlPasteValues

.Cells(1).PasteSpecial Paste:=xlPasteFormats

.Cells(1).Select

Application.CutCopyMode = False

End With

TempFilePath = Environ$("temp") & "\"

TempFileName = "Selection of " & wb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")

If Val(Application.Version) < 12 Then

'You use Excel 97-2003

FileExtStr = ".xls": FileFormatNum = -4143

Else

'You use Excel 2007-2016

FileExtStr = ".xlsx": FileFormatNum = 51

End If

Set OutApp = CreateObject("Outlook.Application")

Set OutMail = OutApp.CreateItem(0)

With Dest

.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum

On Error Resume Next

With OutMail

.to = "ron@debruin.nl"

.CC = ""

.BCC = ""

.Subject = "This is the Subject line"

.Body = "Hi there"

.Attachments.Add Dest.FullName

'You can add other files also like this

'.Attachments.Add ("C:\test.txt")

.Send 'or use .Display

End With

On Error GoTo 0

.Close savechanges:=False

End With

Kill TempFilePath & TempFileName & FileExtStr

Set OutMail = Nothing

Set OutApp = Nothing

With Application

.ScreenUpdating = True

.EnableEvents = True

End With

End Sub

问题是:

1)如何复制特定范围内的任何图表?

2)如何将复制的范围放在.Body区域?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值