Hi Kolein
Welcome to the Forum!!
This Code is untested...if you wish tested Code please attach your File WITH Code.
Option Explicit
Private Sub CommandButton1_Click()
Dim mySheet As String
If Me.CheckBox1 = True Then
Sheets("Confirm").Visible = True
mySheet = "Confirm"
Else
End If
If CheckBox2 = True Then
Sheets("Work Order").Visible = True
mySheet = "Work Order"
Else
End If
If CheckBox3 = True Then
Sheets("Material").Visible = True
mySheet = "Material"
Else
End If
If CheckBox4 = True Then
Sheets("E-Plan").Visible = True
mySheet = "E-Plan"
Else
End If
' Sheets(Array("Confirm", "Work Order", "Material", "E-Plan")).Select
Sheets(mySheet).Activate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Environ("Userprofile") & "\Documents\Emailed Jobs\" & Sheets(mySheet).Range("BA1") & ".pdf", quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Sheets(mySheet).Range("BA2") & Sheets(mySheet).Range("BA3") & Sheets(mySheet).Range("BA4") & Sheets(mySheet).Range("BA5")
.CC = Environ("Username") & "@xxxxxx.co.za"
.BCC = "xxxxxx@xxxxxx.co.za"
.Subject = "Job ready for Execution" & " " & Sheets(mySheet).Range("BA1")
.Body = "Hi." & vbNewLine & vbNewLine & "Please execute the job as per starting and completion dates." & vbNewLine & vbNewLine & "Regards" & vbNewLine & vbNewLine & "CR Section"
.Attachments.Add (Environ("Userprofile") & "\Documents\Emailed Jobs\" & Sheets(mySheet).Range("BA1") & ".pdf")
.send
MsgBox ("Congratulations!" & vbNewLine & vbNewLine & "The job has been saved to PDF and E-mailed")
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Range("AU15").Select
Sheets(mySheet).Select
End Sub
Bookmarks