Emailing from Excel and automatically attaching pdf

Nyge2k3

New Member
Joined
Feb 16, 2015
Messages
11
Hi

I have the following code, which breaks down a file into various pdfs.

If I add a distribution list into column 'D' of the Printing & Distribution Tab, could I then automatically attach the created pdf to an email ready to send to that list? Or, if it's easier, just open the email(s) with the addresses in and ready to go and I can just attach the pdf myself.

Many Thanks

Code:

Sub PDFRoster()

Dim Count, Start, Finish As Integer
Dim DateDay, DateMonth, DateYear As String
Dim fso
Dim Folder, FileName As String

'Get Date of Current Sheet
DateDay = Day(Range("m2"))
DateMonth = Format(Range("m2"), "mmm")
DateYear = Format(Range("m2"), "yyyy")

'Check if PDF Rosters Folder exists, create if not
Folder = ThisWorkbook.Path & "\PDF Rosters"

Set fso = CreateObject("Scripting.FileSystemObject")

If Not fso.FolderExists(Folder) Then

fso.createfolder (Folder)

End If


'Print Local Rosters
For Count = 2 To 6

FileName = Sheets("Printing & Distribution").Cells(Count, 1)
Start = Sheets("Printing & Distribution").Cells(Count, 2)
Finish = Sheets("Printing & Distribution").Cells(Count, 3)

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=Folder & "\WC " & DateDay & " " & DateMonth & " " & FileName & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
From:=Start, To:=Finish, _
OpenAfterPublish:=False

Next

End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,880
Messages
6,175,157
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top