I have created VBA code that checks to see if certain cells on a form have been filled out and then attaches the excel sheet to an email. What I need to do is send the attachment as a pdf instead. I'm at a loss for how I would change the code (see below). Any suggestions appreciated. Thanks!
Sub Mail_small_Text_Outlook()
If Range("f8").Value = "" Or Range("f10").Value = "" Or Range("a29").Value = "" Or Range("j10").Value = "" Or Range("f12").Value = "" Or Range("f14").Value = "" Or Range("k14").Value = "" Or Range("f16").Value = "" Or Range("k16").Value = "" Or Range("H25").Value = "" Or Range("f18").Value = "" Then
MsgBox "Please complete all required fields"
Exit Sub
End If
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Extension request for: " & Sheet1.Range("j10") & vbNewLine & _
"Department: " & Sheet1.Range("f12") & vbNewLine & _
"Classification: " & Sheet1.Range("f18") & vbNewLine & _
"Extension details: " & Sheet1.Range("f20") & vbNewLine & _
"Requestor: " & Sheet1.Range("f14")
On Error Resume Next
With OutMail
.To = "joe.smith@awese.edu"
.CC = ""
.BCC = ""
.Subject = "Extension request for: " & Sheet1.Range("j10")
.Body = strbody
.Attachments.Add ActiveWorkbook.FullName
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Sub Mail_small_Text_Outlook()
If Range("f8").Value = "" Or Range("f10").Value = "" Or Range("a29").Value = "" Or Range("j10").Value = "" Or Range("f12").Value = "" Or Range("f14").Value = "" Or Range("k14").Value = "" Or Range("f16").Value = "" Or Range("k16").Value = "" Or Range("H25").Value = "" Or Range("f18").Value = "" Then
MsgBox "Please complete all required fields"
Exit Sub
End If
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Extension request for: " & Sheet1.Range("j10") & vbNewLine & _
"Department: " & Sheet1.Range("f12") & vbNewLine & _
"Classification: " & Sheet1.Range("f18") & vbNewLine & _
"Extension details: " & Sheet1.Range("f20") & vbNewLine & _
"Requestor: " & Sheet1.Range("f14")
On Error Resume Next
With OutMail
.To = "joe.smith@awese.edu"
.CC = ""
.BCC = ""
.Subject = "Extension request for: " & Sheet1.Range("j10")
.Body = strbody
.Attachments.Add ActiveWorkbook.FullName
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub