Hi all
I am using the below code to send a PDF to a group of managers.
I want to include in the email body, a summary table from one of the tabs.
I want paste as an IMAGE as this keeps all of the formatting and size ratio that makes it easy to read.
The source tab is called DATA and the range of cells I wan to copy and paste is called AA_PASTE_COPY.
Could you tell me where I need to add this in the below code.
Many thanks!
I am using the below code to send a PDF to a group of managers.
I want to include in the email body, a summary table from one of the tabs.
I want paste as an IMAGE as this keeps all of the formatting and size ratio that makes it easy to read.
The source tab is called DATA and the range of cells I wan to copy and paste is called AA_PASTE_COPY.
Could you tell me where I need to add this in the below code.
Many thanks!
Code:
Sub BayEmailPDF()
Dim IsCreated As Boolean
Dim i As Long
Dim PdfFile As String, Title As String
Dim OutlApp As Object
' Not sure for what the Title is
Title = Range("A1")
' Define PDF filename
PdfFile = ""
i = InStrRev(PdfFile, ".")
If i > 1 Then PdfFile = Left(PdfFile, i - 1)
PdfFile = PdfFile & Range("PDFname").Value & ".pdf"
' Export activesheet as PDF
Sheets(Array("Bay", "Coast & Country")).Select
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
Sheets("LIST").Select
' Use already open Outlook if possible
On Error Resume Next
Set OutlApp = GetObject(, "Outlook.Application")
If Err Then
Set OutlApp = CreateObject("Outlook.Application")
IsCreated = True
End If
OutlApp.Visible = True
On Error GoTo 0
' Prepare e-mail with PDF attachment
With OutlApp.CreateItem(0)
' Prepare e-mail
.Subject = Range("EmailSubject").Value
.To = Range("EmailAddressTo").Value ' <-- Put email of the recipient here
.CC = "" ' <-- Put email of 'copy to' recipient here
.Body = "Hi," & vbLf & vbLf _
& "The report is attached in PDF format." & vbLf & vbLf _
& "Regards," & vbLf _
& Application.UserName & vbLf & vbLf
.Attachments.Add PdfFile
' Try to send
On Error Resume Next
.Send
Application.Visible = True
If Err Then
MsgBox "E-mail was not sent", vbExclamation
Else
MsgBox "E-mail successfully sent", vbInformation
End If
On Error GoTo 0
End With
' Delete PDF file
Kill PdfFile
' Quit Outlook if it was created by this code
If IsCreated Then OutlApp.Quit
' Release the memory of object variable
Set OutlApp = Nothing
End Sub
Last edited: