Private Sub cmdEmail_Click()
cmdUpdate_Click
Application.ScreenUpdating = False
Sheets("Packing Slip Rev A").Activate
Dim OL As Object
Dim EmailItem As Object
Dim Wb As Workbook
Dim sAddress As String
Dim sSubject As String
Dim sCustomerEmail As String
Dim sPDFFileName As String
Dim sPSFileName As String
Dim sPDFRawFileName As String
sAddress = Range("A6").Text
sSubject = "Packing Slip For " & Range("B7").Value & " - " & Range("B16").Value & " - " & Range("G16").Value
sCustomerEmail = Range("c10").Text
sPDFRawFileName = "C:\" & Range("B7").Value & " - " & Range("B16").Value & " - " & Range("G16").Value & ""
'Define the postscript and .pdf file names.
sPSFileName = sPDFRawFileName & ".ps"
sPDFFileName = sPDFRawFileName & ".pdf"
' Print the Excel range to the postscript file
ActiveSheet.PrintOut copies:=1, preview:=False, ActivePrinter:="Adobe PDF", printtofile:=True, collate:=True, prtofilename:=sPSFileName
'Create PDF File
Dim myPDFDist As New cAccroDist
Set myPDFDist = New cAccroDist
Call myPDFDist.oDist.FileToPDF(sPSFileName, sPDFFileName, bShowWindow)
'Email PDF File
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Wb = ActiveWorkbook
Wb.Save
With EmailItem
.Subject = sSubject
.Body = "Here is the " & sSubject & ". " & "Thank you"
.CC = ""
.To = ""
.Attachments.Add sPDFFileName
.display
End With
'Clean Up
Dim fso As New FileSystemObject
fso.DeleteFile (sPSFileName)
fso.DeleteFile (sPDFFileName)
Application.ScreenUpdating = True
Set Wb = Nothing
Set OL = Nothing
Set EmailItem = Nothing
Sheets("CoverSheet").Activate
Application.ScreenUpdating = True
End Sub