Sub Send_Player_Participation_Email()
'
' Send_Player_Participation_Email Macro
' Create PDF of active sheet and send as attachment.
'
Dim strPath As String, strFName As String, strFName1 As String, strFName2 As String, strFName3 As String, strFName4 As String, _
strFName6 As String, strFName7 As String, strFName8 As String, strFName9
Dim OutApp As Object, OutMail As Object
'Create New Workbook for Each File
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName = "Binalong 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Binalong Details", "Binalong Player_Records")).Select
Sheets("Binalong Player_Records").Activate
Sheets(Array("Binalong Details", "Binalong Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName1 = "Boorowa Rec 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Bwa Rec Details", "Bwa Rec Player_Records")).Select
Sheets("Bwa Rec Player_Records").Activate
Sheets(Array("Bwa Rec Details", "Bwa Rec Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName1 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName2 = "Boorowa Ex 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Bwa Ex Details", "Bwa Ex Player_Records")).Select
Sheets("Bwa Ex Player_Records").Activate
Sheets(Array("Bwa Ex Details", "Bwa Ex Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName2 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName3 = "Bribbaree 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Bribbaree Details", "Bribbaree Player_Records")).Select
Sheets("Bribbaree Player_Records").Activate
Sheets(Array("Bribbaree Details", "Bribbaree Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName3 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName4 = "Cootamundra 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Coota CC Details", "Coota CC Player_Records")).Select
Sheets("Coota CC Player_Records").Activate
Sheets(Array("Coota CC Details", "Coota CC Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName4 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName5 = "Cootamundra Ex 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Coota Ex Details", "Coota Ex Player_Records")).Select
Sheets("Coota Ex Player_Records").Activate
Sheets(Array("Coota Ex Details", "Coota Ex Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName5 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName6 = "Harden 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Harden Details", "Harden Player_Records")).Select
Sheets("Harden Player_Records").Activate
Sheets(Array("Harden Details", "Harden Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName6 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName7 = "Quandialla 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Quandi Details", "Quandi Player_Records")).Select
Sheets("Quandi Player_Records").Activate
Sheets(Array("Quandi Details", "Quandi Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName7 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName8 = "Stockinbingal 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Stock Details", "Stock Player_Records")).Select
Sheets("Stock Player_Records").Activate
Sheets(Array("Stock Details", "Stock Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName8 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
strPath = "C:\Users\cgrimson\Essential Energy\Boorowa Depot - Documents\SharePoint Docs\Bowls\Pennants 2019\Testing folder\" 'Or any other path, but include trailing "\"
strFName9 = "Young 2019 SWDBA Pennants Player Participation Record " & Format(Date, "DD-MMM-YY")
Sheets(Array("Yng Details", "Yng Player_Records")).Select
Sheets("Yng Player_Records").Activate
Sheets(Array("Yng Details", "Yng Player_Records")).Copy
ActiveSheet.SaveAs FileName:=strPath & strFName9 & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
'Set up outlook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Create message
On Error Resume Next
With OutMail
.To = "[email protected]" 'Insert required address here ########
.CC = "[email protected]"
.BCC = "[email protected]"
.Subject = "SWDBA Pennant Results 2019"
.Body = " Hi All" & vbCr & vbCr _
& " The attached PDF is the updated Pennant Results, Please check the results to see if they are correct" & vbCr & vbCr _
& " Also in the attached PDF is a Skip's Ranking, for Interest" & vbCr & vbCr _
& " If there are any discrepancies, please let me know" & vbCr & vbCr _
& " Regards" & vbCr & vbCr _
& " Chris Grimson" & vbCr
.Attachments.Add strPath & strFName
.Display 'Use only during debugging ##############################
.Send 'Uncomment to send e-mail ##############################
End With
'Delete any temp files created
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Bookmarks