Tristan Shannon
New Member
Hi,
I have been trying to work on a Macro to automatically send an PDF. attached email from excel.
I found one on the internet and tried to modify for my situation. My current code looks like this:
Sub SendSheetAsPDF()
Dim olApp As Object
Path = "I:\GM projects templates\Quantity Surveyor Templates\Purchase Orders\"
Salesman = ActiveSheet.Name
strDate = Format(Date, "ddmmyyyy")
If i > 1 Then PDF_File = Left(PDF_File, i - 1)
PDF_File = "I:\GM projects templates\Quantity Surveyor Templates\Purchase Orders\" & Range("F9").Value
With ActiveSheet
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
PDF_File _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End With
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.Subject = "Report"
.To = "tristan@barretthomes.co.nz"
.Body = "Hi," & vbLf & vbLf _
& "The report is attached in PDF format." & vbLf & vbLf _
& "Regards,"
.Attachments.Add PDF_File
.Send
End With
' if you want to delete it
'Kill PDF_File
olApp.Quit
Set olApp = Nothing
End Sub
If I delete the attachment the email sends okay so its purely just to do with the attachment.
Any help would be greatly appreciated I've been going round and round in circles.
Thanks,
Tristan
I have been trying to work on a Macro to automatically send an PDF. attached email from excel.
I found one on the internet and tried to modify for my situation. My current code looks like this:
Sub SendSheetAsPDF()
Dim olApp As Object
Path = "I:\GM projects templates\Quantity Surveyor Templates\Purchase Orders\"
Salesman = ActiveSheet.Name
strDate = Format(Date, "ddmmyyyy")
If i > 1 Then PDF_File = Left(PDF_File, i - 1)
PDF_File = "I:\GM projects templates\Quantity Surveyor Templates\Purchase Orders\" & Range("F9").Value
With ActiveSheet
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
PDF_File _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End With
Set olApp = CreateObject("Outlook.Application")
With olApp.CreateItem(0)
.Subject = "Report"
.To = "tristan@barretthomes.co.nz"
.Body = "Hi," & vbLf & vbLf _
& "The report is attached in PDF format." & vbLf & vbLf _
& "Regards,"
.Attachments.Add PDF_File
.Send
End With
' if you want to delete it
'Kill PDF_File
olApp.Quit
Set olApp = Nothing
End Sub
If I delete the attachment the email sends okay so its purely just to do with the attachment.
Any help would be greatly appreciated I've been going round and round in circles.
Thanks,
Tristan