This is my first post so bear with me. I'm attempting to create one button that will save my spreadsheet as a PDF in a designated location and then take that same pdf just saved and attach and email it all in one go. Currently it is saving correctly and emailing. It just is not attaching the pdf to the email. I'm very new to VBA as well
Code:
Private Sub Email_Click()
Application.ScreenUpdating = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="O:\Adam\Excel\MOD Report " & Format(Now(), "DD-MMM-YYYY"), _
OpenAfterPublish:=False
Application.ScreenUpdating = True
'Updated by Extendoffice 2017/9/14
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = ""
Dim strFilePath As String
Dim strFileName As String
strFilePath = "O:\Adam\Excel\"
strFileName = "MOD Report" & Format(Now(), "DD-MMM-YYYY")
On Error Resume Next
With xOutMail
.To = "adam.lien@mayociviccenter.com"
.CC = ""
.BCC = ""
.Subject = "MOD Report"
.Body = xMailBody
.Attach = strFilePath & "\" & strFileName
.Send 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub