将工作簿中的文件和图表附加到由excel vba创build的电子邮件中

我不是Excel VBA的提前,但迄今使用本网站。

所以我设法创build了我想要发送电子邮件的表格,并创build了我想发送给读者的电子邮件,但是我被困在如何将图表附加到图片上(我已经将它创build为工作簿中新图片的图片将发送)并将相同的Excel工作簿附加到电子邮件以完成电子邮件并准备发送。

这是我得到了多less:

Sub LFL_makrosu() 'select&copy&paste from sheet to another 'find last row on sheet Dim lRow As Long lRow = Cells(Rows.Count, 1).End(xlUp).Row 'first copy&paste Sheets("Sheet1").Select lRow = Cells(Rows.Count, 1).End(xlUp).Row 'USE CORRECT CELLS ON BELOW CODE Range("A2:B" & lRow).Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.Copy Sheets("Sheet4").Select 'USE CORRECT CELLS ON BELOW CODE Range("A2").Select ActiveSheet.Paste 'second copy&paste Sheets("Sheet2").Select lRow = Cells(Rows.Count, 1).End(xlUp).Row 'USE CORRECT CELLS ON BELOW CODE Range("A2:B" & lRow).Select Selection.SpecialCells(xlCellTypeVisible).Select Application.CutCopyMode = False Selection.Copy Sheets("Sheet4").Select lRow = Cells(Rows.Count, 1).End(xlUp).Row 'USE CORRECT CELLS ON BELOW CODE Range("A" & lRow + 2).Select ActiveSheet.Paste 'third copy&paste Sheets("Sheet3").Select lRow = Cells(Rows.Count, 1).End(xlUp).Row 'USE CORRECT CELLS ON BELOW CODE Range("A2:B" & lRow).Select Selection.SpecialCells(xlCellTypeVisible).Select Application.CutCopyMode = False Selection.Copy Sheets("Sheet4").Select lRow = Cells(Rows.Count, 1).End(xlUp).Row 'USE CORRECT CELLS ON BELOW CODE Range("A" & lRow + 2).Select ActiveSheet.Paste 'create the table and email Call Snapshotandsendmail End Sub Sub Snapshotandsendmail() ' Snapshot Macro Dim lRow As Long lRow = Cells(Rows.Count, 1).End(xlUp).Row 'start creating mail and the table as picture Dim wb As ThisWorkbook Set wb = ThisWorkbook Dim ws As Worksheet Set ws = wb.Sheets("Sheet4") Dim rng As Range Set rng = ws.Range("A2:D18") rng.CopyPicture Dim CH As Chart Set CH = Charts.Add CH.Location xlLocationAsObject, "Sheet4" Set CH = ActiveChart ActiveChart.Parent.Name = "Final_Tablo" ActiveSheet.ChartObjects("Final_Tablo").Height = rng.Height ActiveSheet.ChartObjects("Final_Tablo").Width = rng.Width rng.CopyPicture xlScreen, xlBitmap CH.Paste Call sendemail End Sub Sub sendemail() 'create the email on outlook Dim olook As Outlook.Application Set olook = New Outlook.Application Dim omail As Outlook.MailItem Set omail = olook.CreateItem(olMailItem) With omail .Display End With Signature = omail.HTMLBody Dim fldName1 As String fldName1 = Path & Gun & ".xlsx" 'creates the message on the Email from given date to today - 2 With omail .To = "deniz.beser@koctas.com.tr" .CC = "deniz.beser@koctas.com.tr" .Subject = "LFL Karşılaştırması" .HTMLBody = "<BODY style=font-size:11pt;font-family:calibri>Merhaba, <p>" & "01.01.2017 - 0" & DateAdd("d", -2, Date) & " tarih aralığını içeren; günlük LFL, Koçtaş All Stores Satış & CM & BM% ve bütçe karşılaştırmasını ekte bilgilerinize sunarız.<p>" & vbNewLine & Signature '.Save .Display '.Send End With Set omail = Nothing Set olook = Nothing Set olAtt = Nothing End Sub