Hi,
Can anyone tell me why this code isn't working? I have an excel sheet export to PDF and send as attachment to email. The problem is it's working on my pc but not working on my college pc. On my College pc, the PDF is save to his desktop as on mine, I think it saves to a temp folder? Does anyone know why or what I can do to fix this?
Can anyone tell me why this code isn't working? I have an excel sheet export to PDF and send as attachment to email. The problem is it's working on my pc but not working on my college pc. On my College pc, the PDF is save to his desktop as on mine, I think it saves to a temp folder? Does anyone know why or what I can do to fix this?
VBA Code:
Private Sub CommandButton1_Click()
'Sub SendExcelFilesAsPDFtoEmail()
Dim OutApp As Object
Dim OutMail As Object
Dim Strbody As String, Fname As String
Dim x As Date
x = Format(Now() + 1, "MMMM dd, yyyy")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Fname = "EQ" & Range("F19") & ".pdf"
Strbody = Range("K14")
On Error Resume Next
' Create the PDF attachment
ActiveSheet.ExportAsFixedFormat Type:=x1TypePDF, Filename:=Fname
With OutMail
.Display
.To = Range("K11").Value
.Subject = Range("K13") & " " & x
.HTMLBody = "<p style='font-family:calibri;font-size:14.5'>" & Replace(Strbody, ", ", ",<br/>") & "<br/>" & "" & "</p>" & .HTMLBody
.Attachments.Add Fname
.Importance = 2 'Or olImprotanceHigh Or olImprotanceLow
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Set OutLookMess = Nothing
Set OutLookNSpace = Nothing
End Sub