so I have a sheet that I have set up to email the selected sheet when you click email. It finds the email address in "G14" and sends the email as an xlsx. I have decided I think a PDF will be a b etter format to send so that way the customer doesn't have the option to edit the sheet... I have tried Ron De Bruin's code to no avail... The current code I have looks like this
Now can I use this same code just change a little bit to send as pdf? Or am I opening a whole new batch of problems? Please help???
Code:
Sub Mail_Every_Worksheet()
Dim wb As Workbook
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
TempFilePath = Environ$("temp") & "\"
FileExtStr = ".xlsm": FileFormatNum = 52
End If
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set OutApp = CreateObject("Outlook.Application")
For Each sh In ThisWorkbook.Worksheets
If sh.Range("G14").Value Like "?*@?*.?*" Then
sh.Copy
Set wb = ActiveWorkbook
TempFileName = "Sheet " & sh.Name & " of " _
& ThisWorkbook.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
Set OutMail = OutApp.CreateItem(0)
With wb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
With OutMail
.To = sh.Range("G14").Value
.CC = ""
.BCC = ""
.Subject = "Engine Quote"
.Body = "Here is the engine quote you requested. Please call with any questions. Thank you!"
.Attachments.Add wb.FullName
.Send
End With
On Error GoTo 0
.Close savechanges:=False
End With
Set OutMail = Nothing
Kill TempFilePath & TempFileName & FileExtStr
End If
Next sh
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Now can I use this same code just change a little bit to send as pdf? Or am I opening a whole new batch of problems? Please help???