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
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