redspanna
Well-known Member
- Joined
- Jul 27, 2005
- Messages
- 1,602
- Office Version
- 365
- Platform
- Windows
Hi all
I have code below to auto add a sheet to email with added text to the email body..
is there any way to adapt above code so that a copy of a chart is also added to the email body??
The chart is found on the Report sheet, is called Chart 6
thanks in advance
I have code below to auto add a sheet to email with added text to the email body..
Code:
Sub EmailWithOutlook()
Dim oApp As Object
Dim oMail As Object
Dim WB As Workbook
Dim FileName As String
Dim wSht As Worksheet
Dim shtName As String
Dim StrBody As String
Application.ScreenUpdating = False
' Make a copy of the active worksheet
' and save it to a temporary file
Sheets("Audit Report").Select
ActiveSheet.Copy
Range("A1:AF73").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AH17:AK52").Select
Application.CutCopyMode = False
Selection.ClearContents
Set WB = ActiveWorkbook
FileName = WB.Worksheets(1).Name
On Error Resume Next
Kill "C:\" & FileName
On Error GoTo 0
WB.SaveAs FileName:="C:\Users\Public\" & FileName 'C:\Public\Users" & FileName
'Create and show the Outlook mail item
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
.To = "dsadhjk@abc.com."
.Subject = "Completed Audits"
.body = "Dear xxxx" & vbCrLf & vbCrLf & _
"Please find attached the latest report." & vbCrLf & vbCrLf & _
"Kind regards." & vbCrLf & vbCrLf & _
"John." & vbCrLf & vbCrLf & _
"Auditor - Training."
.Attachments.Add WB.FullName
'.send
.display ' to just display email without sending
End With
'Delete the temporary file
WB.ChangeFileAccess Mode:=xlReadOnly
Kill WB.FullName
WB.Close SaveChanges:=False
'Restore screen updating and release Outlook
Application.ScreenUpdating = True
Set oMail = Nothing
Set oApp = Nothing
End Sub
is there any way to adapt above code so that a copy of a chart is also added to the email body??
The chart is found on the Report sheet, is called Chart 6
thanks in advance